What Is a MIDI File? Tracks, Channels, Ticks and Tempo
A MIDI file is a score for a computer: notes, timing and instrument choices, but no recorded sound.
A MIDI file (.mid or .midi) is a Standard MIDI File, a format published by the MIDI Association. It holds the same messages a keyboard sends to a synthesizer over a MIDI cable: start this note, stop that note, switch to this instrument, press the sustain pedal. It contains no audio, which is why a whole song often fits in a few kilobytes.
Notes, channels and instruments
Each note is stored as two events: a note on with a pitch from 0 to 127 and a velocity (how hard the key was struck, 1 to 127), and later a note off. Middle C is note 60. On this site it is called C4, the most common convention; some programs call it C3 or C5.
Notes and the other channel messages belong to one of sixteen channels. Meta events, such as tempo and time signature changes, belong to no channel. A channel plays one instrument at a time, chosen with a Program Change message. In General MIDI, channel 10 is reserved for drums: there, each note number is a different drum rather than a pitch. See the drum kit map.
Tracks and the three formats
- Format 0 puts all events, for every channel, in a single track.
- Format 1 has several tracks that play together, usually one per instrument. The first track often holds only the tempo, time signature and song title.
- Format 2 stores independent patterns meant to be played one after another. It is rare.
A track is just a way of organising the file; it is not the same as a channel. One track can use several channels, and several tracks can share a channel.
Ticks and tempo
Time in a MIDI file is counted in ticks. The file header says how many ticks make a quarter note, often 96, 480 or 960. How long a tick lasts in seconds depends on the tempo, which the file stores as microseconds per quarter note: 500,000 microseconds is 120 beats per minute. A song can change tempo as often as it likes, so a player has to walk through the tempo changes to know when each note sounds. A few files use SMPTE time instead, counting frames per second as video does.
Meta events
Besides notes, a file can carry meta events: track names, the time signature (such as 3/4), the key signature, markers, copyright text and lyrics. Karaoke files (.kar) are ordinary MIDI files with the words stored as lyric events, one syllable at a time.
See inside your own file
Open a file in the MIDI viewer to see its format, tick resolution, tempo changes, tracks, instruments and every event, with times in seconds and in bars and beats.