MID Format
From ModdingWiki
The Musical Instrument Digital Interface (MIDI) file format is used for storing the notes required to accurately reproduce a song. Commercial instruments are available that "speak" the MIDI protocol, and a MIDI file (.mid) simply stores the data sent over the wire, with a few headers on the front.
Contents |
File format
A MIDI file starts with an overall MThd header, followed by one or more MTrk headers for each "track" (a track is normally created for each instrument, for simplicity when the song is being composed.)
MThd Header
The file begins with a header:
| Data type | Name | Description |
|---|---|---|
| BYTE[4] | cSignature | "MThd" (not NULL-terminated) |
| UINT32LE | iLength | Length of song |
| UINT32LE | ... | TODO |
MTrk block
The MTrk block is repeated once for each track in the song (the iNumTracks field in the MThd header.)
| Data type | Name | Description |
|---|---|---|
| BYTE[4] | cSignature | "MTrk" (not NULL-terminated) |
| UINT32LE | iLength | Length of block |
| UINT32LE | ... | TODO |
| BYTE[iLength] | cData | MIDI data |
MIDI data
The MIDI data consists of a delay value (in MIDI variable-length integer notation), followed by a MIDI event byte (see #MIDI events below.) The event data follows, and will be different depending on the event. It then starts again with the delay value for the next event.
MIDI events
This table lists the different MIDI events that can occur in a song. The events are listed as channel zero (e.g. 0x80, which would become 0x85 for channel five.)
| Register value | Data size | Purpose |
|---|---|---|
| 0x80 | 1 | Note off |
| 0x90 | 2 | Note on |
| 0xA0 | 2 | todo |
| 0xB0 | ? | todo |
| 0xC0 | ? | todo |
| 0xD0 | ? | todo |
| 0xE0 | ? | todo |
Tools
- DRO2MIDI - converts .dro files into .mid files
Similar formats
External links
- http://www.cybermuff.cz/music/MIDIspec.htm - great reference for the MIDI spec
Categories: Stubs | MIDI | File Formats | Music Files | Duke Nukem 3D
