Introduction
A MIDI file stores music as instructions, not sound: which note to play, when, how hard and on which instrument. A synthesiser, a sound card or a sound bank turns the instructions into audio, so the same file sounds different on different devices. The format belongs to MIDI 1.0, the standard for connecting electronic instruments, and is published by the MIDI Association, formerly the MIDI Manufacturers Association. It is used to move songs between sequencers, notation programs and keyboards, and for music in older games and web pages.
The Standard MIDI File was adopted in 1988 and is still at version 1.0. Its later additions, such as new meta events, only add to it: readers skip what they do not know, so every Standard MIDI File since is one format. Versions that only add share a format; a version that changes existing structures is a separate format. The RIFF MIDI file does not change the MIDI data, but puts a complete Standard MIDI File inside a different container, so it is a separate format here.
A MIDI karaoke file (.kar) is an
ordinary Standard MIDI File with the words of the song in its text events.
A .mid or .rmi file dropped on any page of this site opens
in the explorer, which shows its structure chunk by chunk and event by event, with the
notes as a piano roll, the lyrics and a list of every event.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.MID | Standard MIDI File (MThd) | Notes and timing for a synthesiser: a header chunk and track chunks of timed events. | Open |
.RMI | RIFF MIDI file (RMID) | A Standard MIDI File inside a RIFF container, with optional text and an instrument bank. | Open |
The two formats are told apart by their first four bytes: MThd for a
Standard MIDI File, RIFF for a RIFF MIDI file.
Standard MIDI File (MThd)
The MIDI file almost every program reads and writes. A header chunk gives the type, the number of tracks and the timing; track chunks follow, each a list of events with the time since the event before. All numbers are big-endian. Type 0 holds one track, type 1 several tracks played together, and type 2 independent patterns; the type is only the first field of the header, so all three are this format.
The file starts with MThd (4D 54 68 64). It is usually
named .mid, sometimes .midi, .smf or, for
karaoke, .kar.
RIFF MIDI file (RMID)
Microsoft’s wrapper, from the early 1990s: a RIFF container, as in WAV, whose
data chunk holds a complete Standard MIDI File. Other chunks can add text
such as the title and copyright, and an instrument bank (DLS, or a SoundFont) to play
the song with. The RIFF sizes are little-endian; the MIDI file inside keeps its own
big-endian layout.
The file starts with RIFF (52 49 46 46), and the four
bytes at offset 8 are RMID. It is usually named .rmi.
The MIDI 2.0 Clip File is not part of this family. Published by the MIDI Association
and AMEI on 15 June 2023 (document M2-116-U), it stores one MIDI 2.0 sequence as
Universal MIDI Packets, starts with the eight bytes SMF2CLIP
(53 4D 46 32 43 4C 49 50) and uses the extension .midi2 and the
media type audio/midi-clip. It is not built from chunks like a Standard
MIDI File, and a Standard MIDI File reader cannot read it; the explorer does not read
it either.
Versions
The releases that change what goes inside these files. The documents read for this site are RP-001 in its 1996 revision and the later recommended practices, all public downloads from the MIDI Association.
| Date | Release | Format |
|---|---|---|
| August 1983 | MIDI 1.0 specification: the messages between instruments, with no file format | – |
| 1988 | Standard MIDI Files 1.0 adopted by the MIDI Manufacturers Association, later numbered RP-001 | Standard MIDI File |
| 1991 | General MIDI System Level 1 (RP-003): 128 named programs, and percussion on channel 10 | Standard MIDI File, RIFF MIDI file (the names only) |
| 1991 | Microsoft’s Multimedia Programming Interface and Data Specifications 1.0 define RIFF and the RMID form | RIFF MIDI file |
| 1996 | MIDI 1.0 Detailed Specification, document version 96.1, which carries Standard MIDI Files 1.0 | Standard MIDI File |
| 1997 | RP-017: how Lyric (FF 05) events are written, a syllable each, with CR and LF for lines and paragraphs; RP-018: data increment and decrement | Standard MIDI File |
| 1997–2004 | DLS Level 1, the Downloadable Sounds bank format; version 1.1b in 2004 | RIFF MIDI file (the bank) |
| 1998 | RP-019: the Program name (FF 08) and Device name (FF 09) meta events | Standard MIDI File |
| 1998–2000 | CA-018 file reference, CA-019 sample dump extensions, CA-020 and CA-021 tuning extensions, CA-022 controller destination: new universal system exclusive messages | Both |
| 1999 | RP-026: Lyric/Display events, with code set tags, song information, ruby and command codes; General MIDI Level 2 (RP-024): bank 79H variations, 78H drum sets, rhythm channels | Both |
| 2000 | RP-029: a DLS instrument bank bundled with the MIDI file in an RMID file | RIFF MIDI file |
| 2001 | XMF 1.0, which the MMA prefers to RMID for bundling a song with its sounds; RP-032: the XMF patch type prefix meta event (FF 60) | Standard MIDI File (inside XMF) |
| 2006 | DLS Level 2.2; RP-046: the mobile phone control message | Both |
| 2007 | General MIDI 2 version 1.2a, with RP-036, RP-037 and RP-045 | Both |
| 2009 | RP-049: the 3D sound controllers, registered parameters 3D 00 to 08 | Both |
| 2011 | RP-050: MIDI Visual Control | Both |
| 2018–2023 | MIDI-CI: version 1.0 in 2018, 1.1 in 2020, 1.2 in 2023 (which deprecated protocol negotiation): capability inquiry messages, universal sub-ID 0D | Both |
| 2020s | SF2 RMIDI: a SoundFont bank and new INFO entries in an RMID file (a community extension, not an MMA document) | RIFF MIDI file |
| 15 June 2023 | MIDI Clip File (M2-116-U), .midi2 | – (another format) |
| November 2026 | Standard MIDI Files 1.0 is still the current specification | Standard MIDI File |
Not described
Known, not yet covered
- Reference and viewer: the System Exclusive messages that makers publish in their own instrument manuals (Roland, Yamaha, Korg and others give their implementation charts). Only the manufacturer ID is decoded so far; the rest is shown as labelled bytes.
Unknown
- Reference and viewer: System Exclusive data from makers who have not published it, and sequencer-specific (maker’s) meta events, whose contents their makers have not published. Shown as labelled bytes after the maker is named.
Links
Software
- MuseScore – free notation program that imports and exports MIDI files as scores (Windows, macOS, Linux)
- REAPER – low-cost digital audio workstation that imports and exports MIDI (Windows, macOS, Linux)
- Logic Pro – Apple’s professional music production app (macOS)
- GarageBand – Apple’s free music app, which opens MIDI files as tracks (macOS, iOS)
- FL Studio – Image-Line’s music production software (Windows, macOS)
- Ableton Live – music production software that imports and exports MIDI clips (Windows, macOS)
- Cubase – Steinberg’s music production software (Windows, macOS)
- TiMidity++ – software synthesiser that plays MIDI files (Windows, macOS, Linux)
- Windows Media Player – Microsoft’s media player, built into Windows, which plays MIDI and RMI files (Windows)
Developers
- Mido – library that reads and writes MIDI files (Python)
- midifile – library for reading and writing Standard MIDI Files (C++)
- pretty_midi – reads and writes MIDI files, with note and tempo helpers (Python)
- @tonejs/midi – reads and writes MIDI files as JSON (JavaScript)
- FluidSynth – synthesiser library that plays MIDI files with SoundFonts (C)
- SpessaSynth – SoundFont synthesiser and player that reads MIDI and RMI files with embedded banks (JavaScript)
Reference
- Standard MIDI Files – the MIDI Association’s page with RP-001 and the recommended practices for MIDI files (RP-017, RP-019, RP-026, RP-032) to download
- General MIDI Level 1 – the MIDI Association’s page on General MIDI 1
- RMID – the Library of Congress’s description of the RIFF MIDI file
- MIDI Clip File Specification – AMEI’s copy of M2-116-U, the MIDI 2.0 clip file