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. |
vers | The version of the contents (RP-029). Optional; second when present. |
DISP | Something to display for the file. 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
RP-029 says the data chunk must be the first chunk in the RMID form, as
in Microsoft’s original definition, so the MIDI file starts at offset 20; other chunks
may follow it. A minimal file is just the RIFF chunk and the data chunk, 20 bytes
before the MIDI file. 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. The explorer still finds a data chunk that is not first, and reports it.
The version chunk
RP-029 adds an optional vers chunk for the version of the file’s
contents, not of the format: recommended for every RMI file with DLS data, and placed
second, straight after data and before any INFO list.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 LE | dwVersionMS | The high 32 bits: its high and low words are the first two numbers |
| 4 | 4 | u32 LE | dwVersionLS | The low 32 bits: the last two numbers |
The four numbers follow a Windows program’s version resource: version 3,10,0,61 is
dwVersionMS = 0003000A and dwVersionLS =
0000003D. The numbering scheme is the author’s choice. The same chunk is
used in DLS files.
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 RIFF INFO IDs of
the standard, with what SF2 RMIDI says of them. RP-029 puts the INFO list after the
data chunk (and after vers), with the file’s copyright in
ICOP; a separate copyright for the MIDI data goes in a
copyright meta event,
and a DLS bank keeps its own INFO lists inside it. RP-029 repeats the standard’s
conventions: several copyrights, engineers or keywords are separated by a semicolon
and a space; ICRD is year-month-day, as 1553-05-03, with a four-digit
year; comments in ICMT have no newlines; an application ignores any ID it
does not know.
| ID | Meaning | ID | Meaning |
|---|---|---|---|
INAM | Name, the title | IMED | Medium |
ICOP | Copyright | IPRD | Product (SF2 RMIDI: album) |
IART | Artist (SF2 RMIDI: the MIDI creator) | ISBJ | Subject |
ICMT | Comments | ISFT | Software |
ICRD | Creation date | ISRC | Source |
IENG | Engineer (SF2 RMIDI: the SoundFont creator) | ISRF | Source form |
IGNR | Genre | ITCH | Technician |
IKEY | Keywords | IARL | Archival location |
ICMS | Commissioned | ICRP | Cropped |
IDIM | Dimensions | IDPI | Dots per inch |
ILGT | Lightness | IPLT | Palette |
ISHP | Sharpness |
The last eight come from the same RIFF standard and are for image files; the explorer names them if they appear.
SF2 RMIDI entries
The SF2 RMIDI extension adds entries, and rules for the ones above. Chunk order inside INFO is free. Text ends with a zero byte, and zero-length entries are illegal and discarded.
| ID | Meaning |
|---|---|
IENC | The encoding of the INFO text, a lower-case name such as utf-8 or shift-jis. Level 3 readers must handle UTF-8, Shift JIS and Windows-1250 to 1258. Without it, any encoding may be used, UTF-8 being recommended. |
MENC | A hint for the encoding of the MIDI file’s text events, in the same form. Without it the reader chooses. |
DBNK | The bank offset, exactly two bytes, a 16-bit little-endian number 0 to 127. A wrong length or out-of-range value means rejecting the file. The default is 1 if the entry is missing and the file has a bank, 0 if it has no embedded bank. It is added to every preset’s bank except 128, the drums; a result outside 0 to 127 is clamped to 0. |
IALB | The album. IPRD and IALB are interchangeable; if both exist, use IALB. |
IPIC | A picture such as album art; PNG or JPEG are recommended. |
ICRD should be ISO 8601. INAM, when present, is shown as the
title instead of the MIDI track name. The explorer applies these: it reads the text
with IENC when it names an encoding it knows, uses IALB over
IPRD, shows the picture, and reports a DBNK of the wrong
size or range and a zero-length entry.
The chunks of an SF2 RMIDI file come in the order data,
INFO, then the bank; a file with any other order should be rejected.
The explorer reports it. A file with no bank uses the main SoundFont with bank offset
0 and ignores DBNK.
Display chunk
A DISP chunk can hold something to show for the file, in a Windows
clipboard format: a 32-bit little-endian format number, then the data. This is the
standard RIFF display chunk and is not part of RP-029.
| Number | Format | Number | Format |
|---|---|---|---|
| 1 | CF_TEXT, text ending in a zero byte | 10 | CF_PENDATA, pen data |
| 2 | CF_BITMAP, a device-dependent bitmap | 11 | CF_RIFF, RIFF data |
| 3 | CF_METAFILEPICT, a Windows metafile picture | 12 | CF_WAVE, a WAVE sound |
| 4 | CF_SYLK, Symbolic Link format | 13 | CF_UNICODETEXT, UTF-16 text |
| 5 | CF_DIF, Data Interchange Format | 14 | CF_ENHMETAFILE, an enhanced metafile |
| 6 | CF_TIFF, a TIFF image | 15 | CF_HDROP, a list of files |
| 7 | CF_OEMTEXT, text in the OEM code page | 16 | CF_LOCALE, a locale identifier |
| 8 | CF_DIB, a device-independent bitmap | 17 | CF_DIBV5, a bitmap with a version 5 header |
| 9 | CF_PALETTE, a colour palette |
The explorer names every format, shows text (1, 7 and 13) as text, and shows a device-independent bitmap (8 and 17), which has no file header, as a picture. The others are shown as bytes.
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, the last chunk | RP-029 (2000) |
sfbk (73 66 62 6B) | A SoundFont 2 bank; SF3 is also allowed | SF2 RMIDI |
RP-029 (a technical note of February 2000, no longer on midi.org but kept by the
Internet Archive and linked by the Library of Congress) says an extended RMI file holds
a single MIDI file, a single DLS bank and supplemental data such as a version, a
copyright and other text; it defines no use for more than one of either, or for other
chunks. The DLS bank is added by appending the whole DLS form, unchanged, as a nested
RIFF 'DLS ' chunk at the end of the RMID form and adding its size to the
RMID size. DLS keeps its own copyright notices in INFO lists inside the bank.
Encryption is outside the format: a whole RMID file may sit in an encrypted container,
or proprietary chunks with other IDs may hold encrypted parts. DirectMusic 7 and later
plays such files with their DLS instruments.
The explorer reads both kinds of bank in full: every chunk and field, the instruments and presets as tables, and each wave or sample as a file you can open and play.