An RMI file is a RIFF file: one RIFF chunk whose form type is
RMID, holding further chunks. One of them, data, is the MIDI
file. All sizes in the container are 32-bit little-endian, least
significant byte first, unlike the big-endian numbers of the MIDI file inside.
52 49 46 46 <size> 52 4D 49 44 "RIFF" size "RMID"
64 61 74 61 <size> 4D 54 68 64 … "data" size, then the MIDI file
[00] pad byte if the data size is odd
4C 49 53 54 <size> 49 4E 46 4F … "LIST" size "INFO", then INAM, ICOP …
52 49 46 46 <size> 44 4C 53 20 … "RIFF" size "DLS ", the bank
No RMI file was among the files examined for this site, so the explorer’s reading is tested on files built to the specifications.
The RIFF header
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | ASCII | id | RIFF (52 49 46 46). |
| 4 | 4 | u32 LE | size | The bytes after this field: the form type and every chunk. The file size minus 8. |
| 8 | 4 | ASCII | form | RMID (52 4D 49 44). |
| 12 | … | chunks | The chunks below, to the end of the RIFF chunk. |
When the size runs past the end of the file, the file has been cut short; the explorer reads what is there and says so. Bytes after the end of the RIFF chunk are not part of the file.
Chunks
Every chunk inside has the same layout:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | ASCII | id | The chunk ID, four characters, such as data or LIST. |
| 4 | 4 | u32 LE | size | The bytes of data that follow, not counting the pad byte. |
| 8 | size | data | The chunk’s contents. | |
8 + size | 0 or 1 | pad | One byte, normally zero, when size is odd, so that the next chunk starts at an even offset. |
| Chunk | What it holds |
|---|---|
data | The MIDI file. Exactly one. |
LIST of type INFO | Text about the file. Optional. |
RIFF of form DLS or sfbk | An instrument bank. Optional. |
| anything else | Skipped, as RIFF readers skip every chunk they do not know. |
Some writers leave out the pad byte after a chunk of odd size. When the byte after such a chunk is not zero and starts what looks like a chunk ID, the explorer takes it that the pad was left out and says so.
The data chunk
The data chunk holds a complete Standard MIDI File, byte for byte,
starting MThd, in its own big-endian layout:
- Chunks and header – the
MThdheader and the chunks of the MIDI file - Track chunks and events – delta times, running status and timing
- Channel messages – notes, controllers, programs and pitch bend
- Meta events – names, text, tempo and signatures
- System exclusive events – sysex messages, packets and escapes
Readers find the chunk by its ID. RP-029 and SF2 RMIDI put it first, at offset 12,
so the MIDI file usually starts at offset 20, but other chunks may come before it.
The chunk’s size is the length of the MIDI file. A file without a data
chunk is not an RMI file; if there is a second one, readers use the first.
LIST INFO
A LIST chunk begins with a four-character list type. For
INFO, the rest is a series of sub-chunks, each with the chunk layout and
padding above, holding text that ends in a zero byte. These are the standard RIFF INFO
IDs:
| ID | Meaning | ID | Meaning |
|---|---|---|---|
INAM | Name, the title | IMED | Medium |
ICOP | Copyright | IPRD | Product |
IART | Artist | ISBJ | Subject |
ICMT | Comments | ISFT | Software |
ICRD | Creation date | ISRC | Source |
IENG | Engineer | ISRF | Source form |
IGNR | Genre | ITCH | Technician |
IKEY | Keywords |
SF2 RMIDI adds entries of its own:
| ID | Meaning |
|---|---|
IENC | The encoding of the INFO text |
MENC | A hint for the encoding of the text events in the MIDI file |
DBNK | Two bytes, a 16-bit little-endian bank offset, 0 to 127; 1 when it is missing |
IALB | Album |
IPIC | A picture, such as album art |
The explorer shows text entries as Windows-1252, without the closing zero.
Instrument banks
An RMI file can carry the instruments to play the song with, as a nested
RIFF chunk:
| Form type | Bank | Defined by |
|---|---|---|
DLS (44 4C 53 20) | A Downloadable Sounds collection | RP-029 (2000) |
sfbk (73 66 62 6B) | A SoundFont 2 bank; SF3 is also allowed | SF2 RMIDI |
RP-029 says an RMI file holds one MIDI file, at most one DLS bank and supplemental data such as a version and copyright text. Files with an embedded bank seem to be rare. The banks’ own formats are not described here, and the explorer shows them as bytes.