MIDI is the most important file format in music that most people have never opened. It doesn't store audio — it stores musical instructions. A MIDI file is essentially a player piano roll: a sequence of "play note X at time Y with velocity Z" messages that a synthesizer, sampler, or virtual instrument interprets and turns into sound.
What Is MIDI?
MIDI (Musical Instrument Digital Interface) is both a protocol and a file format. The protocol (defined in 1983 by a consortium of synthesizer manufacturers including Roland, Yamaha, Korg, and Sequential Circuits) allows electronic musical instruments, computers, and devices to communicate in real time. The MIDI file format (.mid or .midi) records this communication as a sequence of time-stamped events for playback and sharing.
A MIDI file contains no audio whatsoever. It contains:
- Note On/Off events: which note (0–127 MIDI note numbers, where 60 = middle C), when, and at what velocity (volume)
- Program Change: which instrument sound to use (1–128 General MIDI instruments)
- Control Change (CC): real-time controls — sustain pedal (CC64), modulation wheel (CC1), volume (CC7), pan (CC10)
- Pitch Bend: continuous pitch variation
- Tempo changes: BPM markers
- Time signature: how beats are grouped
- Lyrics: synchronized text (karaoke)
- Track names and metadata
MIDI File Structure
A MIDI file is a binary file with a specific chunk structure:
Header Chunk (MThd): format type (0 = single track, 1 = multi-track synchronous, 2 = multi-track asynchronous), number of tracks, timing resolution (ticks per quarter note).
Track Chunks (MTrk): sequences of events. Each event has: a delta time (time since last event, in ticks), an event type (status byte), and data bytes.
MIDI vs Audio Formats
| Property | MIDI | MP3/WAV/FLAC |
|---|---|---|
| Contains audio | ❌ Instructions only | ✅ |
| File size | Tiny (few KB to ~1 MB) | Large (1–50+ MB) |
| Editable | ✅ Every note | ❌ (destructive) |
| Tempo change | ✅ Lossless | ❌ Audio artifacts |
| Sound quality | Depends on synthesizer | Fixed (as recorded) |
| Transpose | ✅ Lossless | ❌ Quality loss |
| Instrument change | ✅ Instantly | ❌ |
| Karaoke | ✅ Synchronized lyrics | ❌ |
| Music theory data | ✅ | ❌ |
General MIDI (GM) Standard
General MIDI (1991) standardizes 128 instrument sounds to a common map, so MIDI files play consistently across different devices:
- Program 1: Acoustic Grand Piano
- Program 25: Acoustic Guitar (nylon)
- Program 41: Violin
- Program 57: Trumpet
- Program 81: Lead 1 (square wave synth)
- Program 129–136: Percussion (on Channel 10, which is always drums)
MIDI File Uses
- Music production: DAWs (Digital Audio Workstations) like Ableton Live, FL Studio, Logic Pro, and GarageBand use MIDI extensively. Producers record MIDI from keyboards, quantize timing, edit notes in piano roll, then route through virtual instruments.
- Music notation: Sibelius, MuseScore, Finale import and export MIDI — convert compositions to/from sheet music
- Karaoke:
.mid+.cdg(lyrics graphics) = karaoke track. MIDI karaoke files embed lyrics directly. - Video game music: early game soundtracks were MIDI played through OPL chips (Sound Blaster) or SNES's SPC chip. DOOM, Warcraft II, and hundreds of DOS-era games used MIDI.
- Digital pianos and keyboards: all modern digital pianos support MIDI over USB for recording and controlling software
Converting MIDI Files
MIDI to MP3/WAV (audio render):
# FluidSynth (free, uses SoundFont)
fluidsynth -F output.wav /usr/share/sounds/sf2/FluidR3_GM.sf2 input.mid
ffmpeg -i output.wav output.mp3
# timidity++ (alternative)
timidity input.mid -Ow -o output.wav
MIDI to sheet music (notation):
- MuseScore (free): File → Import → select .mid → generates sheet music notation
- Sibelius, Finale: similar import function
MIDI to MusicXML:
# MuseScore CLI
mscore -o output.mxl input.mid
Audio to MIDI (transcription — the hard direction):
- This converts audio to MIDI, estimating the notes played. Results vary with source material.
- Tools: Melodyne (professional, excellent for single instruments), AnthemScore, Celemony
- Free option: MuseScore 4's audio-to-score feature (basic polyphonic transcription)
Tips for MIDI Users
- SoundFonts matter: the same MIDI file sounds completely different through a Roland SC-88 hardware synth vs Windows GS Wavetable vs a sample-based virtual instrument. Quality SoundFonts (like SGM-V2.01 or Yamaha S-YXG50) dramatically improve MIDI playback.
- Channel 10 is always drums: in General MIDI, MIDI channel 10 (sometimes written as channel 9 in zero-indexed contexts) is permanently assigned to percussion. Notes on channel 10 trigger drum sounds regardless of the program change.
- Quantization: DAWs quantize MIDI timing to a grid (1/16th note, 1/32nd note) to correct timing imprecision from live recording. Too much quantization sounds robotic; none sounds sloppy.
- Velocity = dynamics: MIDI velocity (1–127) controls how loudly a note plays. A velocity of 64 is medium; 127 is maximum. Expressive MIDI playing varies velocity extensively.
Related conversions
Audio format pairs that come up most often: