The basics
What is a MIDI file?
A MIDI file is sheet music for machines. It doesn't record sound; it records performance instructions: press this key at this moment, this hard, on this channel; switch channel 10 to drums; slow down here. A synthesizer, a sound card, a software instrument or a phone's built-in synth turns the instructions into sound when the file is played.
MIDI (Musical Instrument Digital Interface) began in 1983 as a way for electronic instruments to talk to each other over a cable. The Standard MIDI File format was added in 1988, so that sequences could be moved between different programs and devices. It has hardly changed since, and almost every music program can still read and write it.
Storing instructions instead of sound has big consequences:
- Files are tiny. A whole song is often a few kilobytes, where a WAV of it would be tens of megabytes and an MP3 a few.
- Everything stays editable. You can change a wrong note, the tempo, the key or an instrument after the fact, and notation software can turn the file into a score.
- The sound depends on the player. The same file played by a cheap phone synth, a Windows PC and a professional sample library sounds completely different (see General MIDI below).
- Vocals and real recordings can't be stored. A MIDI file can hold lyrics as text, but not a singer's voice.
Anatomy
What's inside a MIDI file
A Standard MIDI File is a header chunk followed by track chunks, each with a 4-letter ID and a 32-bit length. Inside a track, every event starts with a delta time: how many ticks to wait after the previous event. Here is every byte of a 64-byte file we wrote for this page with the Python package mido: a C and an E played together on a piano for one second.
tiny.mid: format 0, one track, 64 bytes
offset bytes part
0 4D 54 68 64 "MThd": header chunk
4 00 00 00 06 length: 6 bytes
8 00 00 format 0: one track
10 00 01 number of tracks: 1
12 00 60 division: 96 ticks per quarter note
14 4D 54 72 6B "MTrk": track chunk
18 00 00 00 2A length: 42 bytes
22 00 FF 03 09 39 39 68 … Δ0 track name: "99helpers"
35 00 FF 51 03 07 A1 20 Δ0 set tempo: 500,000 µs per beat
42 00 C0 00 Δ0 program change, channel 1: 0
45 00 90 3C 64 Δ0 note on, channel 1: 60, velocity 100
49 00 40 64 Δ0 (running status) note on: 64
52 81 40 80 3C 00 Δ192 note off: 60
57 00 40 00 Δ0 (running status) note off: 64
60 00 FF 2F 00 Δ0 end of track
64 end of file- 1
4D 54 68 64 · 00 00 00 06The header chunk
MThdand a length that's always 6 in current files. Readers should still use the length to find the end of the chunk rather than assume 6. - 2
00 00 · 00 01Format and track count
Format 0 puts everything in one track, and this file has 1 track. Format 1 files have several tracks played together; format 2, rarely used, holds independent sequences.
- 3
00 60Division
96 ticks per quarter note: the unit for every delta time in the file. When the top bit is set, the division counts frames and subframes of SMPTE timecode instead.
- 4
4D 54 72 6B · 00 00 00 2AThe track chunk
MTrkand the number of bytes of events that follow: 42. A format 1 file has one of these per track, one after the other. - 5
00 FF 03 09 …Meta events
FF, a type and a length. Type03is the track name. Meta events carry information for the sequencer, not the instrument: tempo, time signature, lyrics, markers. - 6
00 FF 51 03 07 A1 20Set tempo
07 A1 20is 500,000 microseconds per quarter note: 120 beats per minute. A file with no tempo event is played at 120 bpm. - 7
00 C0 00Program change
C0is a program change on channel 1 (channels are numbered 0 to 15 in the bytes, 1 to 16 in apps). Program 0 is Acoustic Grand Piano in General MIDI. - 8
00 90 3C 64Note on
90is note on, channel 1;3Cis note 60, middle C;64is a velocity of 100, how hard the key was struck. The file says nothing about what a piano sounds like. - 9
00 40 64Running status
No status byte: when an event has the same status as the one before, the status byte can be left out. This is the second note on, for note 64 (E).
- 10
81 40 80 3C 00A variable-length delta time
81 40means wait 192 ticks (two beats, one second at 120 bpm). Each byte gives 7 bits; a set top bit means another byte follows: (1 × 128) + 64 = 192. Then80 3C 00: note off for middle C. - 11
00 FF 2F 00End of track
Every track must end with this meta event. A reader that finds the chunk length and this event disagreeing is looking at a damaged file.
Under the hood
Chunks, formats 0, 1 and 2, and timing
A Standard MIDI File is a series of chunks, each a 4-character type, a 32-bit length (most significant byte first) and the data. There's one header chunk, MThd, then one or more track chunks, MTrk. Readers are expected to skip chunk types they don't know. The header's format field says how the tracks relate:
| Format | Tracks | Used for |
|---|---|---|
| 0 | Exactly one, holding every channel | Simple playback devices, ringtones, the most widely playable files |
| 1 | Several, played at the same time; the first usually holds the tempo map | What DAWs and notation programs export: one track per instrument or part |
| 2 | Several independent sequences, each with its own timing | Collections of patterns; rarely used |
Time is counted in ticks. The header's division usually says how many ticks make a quarter note (values such as 96, 480 or 960), and tempo events say how many microseconds a quarter note lasts. A tick therefore has no fixed length: changing the tempo changes how long every following tick takes. If a file has no tempo or time signature events, the specification says to assume 120 beats per minute and 4/4.
Format 1 files written by a DAW typically start with a "conductor" track that has no notes, only tempo, time signature and key signature events. A simple player that only plays the first track plays nothing at all.
Under the hood
Events, delta times and running status
A track is a list of events, each preceded by a delta time: the number of ticks since the previous event, so events that happen together have a delta of 0. Delta times and some lengths are written as variable-length quantities: 7 bits per byte, most significant first, with the top bit set on every byte except the last. Small numbers take one byte, and the largest allowed value, 0FFFFFFF, takes four.
| Value | Hex | Stored as |
|---|---|---|
| 0 | 00 | 00 |
| 127 | 7F | 7F |
| 128 | 80 | 81 00 |
| 192 | C0 | 81 40 |
| 16,383 | 3FFF | FF 7F |
| 268,435,455 (the maximum) | 0FFFFFFF | FF FF FF 7F |
There are three kinds of event:
| Starts with | Kind | Examples |
|---|---|---|
80 to EF | Channel messages: the MIDI messages an instrument receives. The low 4 bits are the channel | 8n note off, 9n note on, Bn control change (volume, pan, sustain pedal), Cn program change, En pitch bend |
FF | Meta events: information for the sequencer | FF 03 track name, FF 05 lyric, FF 51 tempo, FF 58 time signature, FF 59 key signature, FF 2F 00 end of track |
F0, F7 | System exclusive (SysEx): manufacturer-specific data, with a length | Resets a synth to General MIDI, or sets up a particular keyboard's sounds |
Running status saves space: if a channel message has the same status byte as the previous one, the status byte can be left out, as in the anatomy above. Meta and SysEx events cancel running status, so the next channel message must start with its status byte again. This is also why many files end notes with a note on with velocity 0 instead of a note off: the specification treats the two the same, and staying on note-on status lets a whole passage use running status.
General MIDI
Why a MIDI file sounds different on every device
A program change only says "instrument number 0". What number 0 sounds like is up to the synthesizer. Early on, every manufacturer numbered its sounds differently, so a file made on one keyboard could play a piano part as a trumpet on another.
General MIDI (GM), published in 1991 by the MIDI Manufacturers Association and the Japan MIDI Standards Committee, fixed this. It assigns a named instrument to each of 128 program numbers (0 is Acoustic Grand Piano), reserves channel 10 for percussion, with each note number a different drum, and requires at least 24 voices at once. General MIDI 2 (1999) added more sounds and controllers; Roland's GS and Yamaha's XG were earlier supersets.
GM guarantees the right instruments, not the same sound. The piano on a phone, the one built into Windows and a 2 GB sampled piano are all program 0. Software synths load their instruments from a SoundFont (.sf2) or a similar sample library, so changing the SoundFont changes the sound of every MIDI file you play. If a file must sound exactly as the composer heard it, export it as audio.
Comparison
MIDI vs MP3 and WAV
| MIDI | MP3 | WAV | |
|---|---|---|---|
| Contains | Notes and controls | Compressed audio | Uncompressed audio |
| Size for 3 minutes | Usually kilobytes | About 2.9 MB at 128 kbps | About 32 MB at CD quality |
| Sounds the same everywhere | No: depends on the synth | Yes | Yes |
| Edit notes and tempo | Yes | No | No |
| Can hold vocals | No (lyrics as text only) | Yes | Yes |
| Plays in a browser | No | Yes | Yes |
Use MIDI to move music between programs, to edit or rearrange it, to drive hardware instruments, or to turn it into notation. Use MP3, WAV or another audio format to let people hear a finished piece.
How to
How to play, open and convert a MIDI file
- On a Mac: drag the file into a software instrument track in GarageBand; it appears as one or more tracks, and you can choose the instrument that plays each.
- As sheet music: MuseScore (free, Windows, macOS, Linux) opens
.mid,.midiand.karfiles and converts them to notation. The result needs tidying, because a MIDI file has timing, not note spelling or layout. - With VLC: VLC plays MIDI through its FluidSynth module, which needs a SoundFont: in Preferences, show All settings, go to Input/Codecs › Audio codecs › FluidSynth, and choose an
.sf2file. On Windows, MIDI playback is available in VLC 3.0 and later. - On Windows: Windows has a built-in General MIDI synthesizer with a sound set provided by Roland, which apps can play through. Which media app plays a double-clicked
.midhas varied between Windows versions; VLC with a SoundFont is a dependable choice. - In a browser: browsers don't play MIDI files. The Web MIDI API lets a page talk to connected MIDI devices, and web players use JavaScript synths, but an
<audio>element won't play a.mid.
To turn a MIDI file into audio, play it through a synthesizer and record or export the result: in a DAW such as GarageBand, export the song as audio; on the command line, the free FluidSynth synthesizer renders MIDI files to WAV with a SoundFont.
To make or inspect one in code, the Python package mido (pip install mido) reads and writes Standard MIDI Files. This script writes the 64-byte file from the anatomy above:
import mido
mid = mido.MidiFile(type=0, ticks_per_beat=96)
track = mido.MidiTrack()
mid.tracks.append(track)
track.append(mido.MetaMessage("track_name", name="99helpers", time=0))
track.append(mido.MetaMessage("set_tempo", tempo=500000, time=0)) # 120 bpm
track.append(mido.Message("program_change", program=0, time=0)) # piano
track.append(mido.Message("note_on", note=60, velocity=100, time=0))
track.append(mido.Message("note_on", note=64, velocity=100, time=0))
track.append(mido.Message("note_off", note=60, velocity=0, time=192))
track.append(mido.Message("note_off", note=64, velocity=0, time=0))
mid.save("tiny.mid") # mido adds the end-of-track eventVariants
RMID, karaoke files, and MIDI 2.0 Clip Files
.rmi(RIFF MIDI): a Standard MIDI File wrapped in a RIFF chunk, the container also used by WAV. Microsoft documented it in 1991, and a 2000 MIDI Manufacturers Association note extended it to carry Downloadable Sounds (DLS) instruments with the music..kar: karaoke files, which MuseScore and many players accept as MIDI files.- XMF: the Extensible Music Format, a container for MIDI and sounds that the MIDI Manufacturers Association published in 2001, with a Mobile XMF variant for phones.
MIDI 2.0 was adopted by AMEI and the MIDI Association in January 2020. It sends messages as Universal MIDI Packets of 32 to 128 bits, with 256 channels in 16 groups. The Standard MIDI File itself didn't change: MIDI 2.0 added new file formats next to it.
The MIDI 2.0 counterpart of a format 0 file is the MIDI Clip File (specification M2-116-U, version 1.0, June 2023): one sequence of Universal MIDI Packets, starting with the 8 bytes SMF2CLIP. It uses the extension .midi2 and the media type audio/midi-clip, registered with IANA in March 2024. A companion MIDI Container File, comparable to format 1, holds one or more clips on several tracks. For exchanging music with most software today, use a Standard MIDI File.
Troubleshooting
Common MIDI problems
- It plays silence. There's no synthesizer behind the player: VLC needs a SoundFont, and some systems have no default MIDI output. It may also be a format 1 file played by something that only plays the first (conductor) track.
- The instruments are wrong. The file has no program changes, or uses GS or XG bank selections the synth doesn't know, or was made for a specific keyboard rather than General MIDI.
- The drums are piano notes. The drum part isn't on channel 10, the General MIDI percussion channel.
- It's too fast or too slow. The tempo events are missing (players then assume 120 bpm) or were lost in conversion.
- A note keeps sounding. A note on has no matching note off (or note on with velocity 0), often in a file that was cut short. Stop playback, or fix the file in an editor.
- The imported score is messy. MIDI records timing in ticks, not note values, ties or enharmonic spelling. Adjust the quantization in the import settings, or clean the score up by hand.
Security
Is a MIDI file safe?
A MIDI file holds musical events, not code. Two things are still worth knowing:
- Parser bugs. Like any binary format, MIDI has length fields a crafted file can lie about. VideoLAN removed MIDI playback from VLC on Windows in version 2.1.0 for security reasons, and restored it in 3.0. Keep players and libraries up to date.
- SysEx reaches your hardware. System exclusive messages in a file are sent to whatever device plays it, and can change that synthesizer's settings or stored sounds. Be careful playing untrusted files into a hardware instrument you've set up by hand.
Sample files
There are no sample MIDI files on this page yet. To make one for testing, install mido (pip install mido) and run the short script under How to play, open and convert, which writes the 64-byte file shown in the anatomy.
Put it online
Have a MIDI file? Give it a link.
Drop a .mid file on 99helpers and it gets its own web address. Browsers don't play MIDI, so visitors download the file to open in GarageBand, MuseScore, VLC or their own music software; add an MP3 next to it if people just need to hear it.
Questions
MIDI files, frequently asked
What is a MIDI file?
A Standard MIDI File (.mid): a list of musical instructions, such as which notes to play, when and on which instrument, that a synthesizer turns into sound. It contains no recorded audio.
Why does my MIDI file sound different on another computer?
Because the file only names instruments; each device's synthesizer or SoundFont decides what they sound like. General MIDI makes sure a piano part is played by a piano, not that every piano sounds the same.
How do I play a MIDI file?
Open it in GarageBand or MuseScore, or play it in VLC after choosing a SoundFont in its FluidSynth settings. Web browsers can't play MIDI files.
How do I convert MIDI to MP3?
Play it through a synthesizer and export the audio: in a DAW such as GarageBand, export the song as an audio file. The result sounds like whichever instruments you used.
What's the difference between .mid and .midi?
None: both are Standard MIDI Files. .mid is the more common extension.
What's the difference between MIDI format 0 and format 1?
Format 0 has a single track containing all channels; format 1 has several tracks played together, usually one per instrument. Format 0 plays on the most devices; format 1 keeps parts separate for editing.
Can a MIDI file contain vocals?
No. It can contain lyrics as text events, which karaoke players show, but not recorded sound. For a song with vocals, use an audio format such as MP3 or WAV.
Is there a MIDI 2.0 file format?
Yes: the MIDI Clip File (.midi2), published in 2023, stores MIDI 2.0 Universal MIDI Packets. For exchange with most music software, a Standard MIDI File is still the safer choice.
Related formats
Other file types explained
Keep going
Related
Sources
- Standard MIDI Files 1.0: chunk descriptions (IEEE Computer Society Press edition)
- Standard MIDI Files 1.0: meta-events (IEEE Computer Society Press edition)
- The MIDI Association: MIDI Clip File Specification
- IANA: audio/midi-clip media type registration
- Wikipedia: General MIDI
- VideoLAN Wiki: MIDI playback in VLC
- Library of Congress: RIFF-based MIDI File Format (RMID)
Last reviewed 27 October 2026.