MID Format

From ModdingWiki

Jump to: navigation, search

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 typeNameDescription
BYTE[4]cSignature"MThd" (not NULL-terminated)
UINT32LEiLengthLength 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 typeNameDescription
BYTE[4]cSignature"MTrk" (not NULL-terminated)
UINT32LEiLengthLength of block
UINT32LE...TODO
BYTE[iLength]cDataMIDI 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 valueData sizePurpose
0x801Note off
0x902Note on
0xA02todo
0xB0?todo
0xC0?todo
0xD0?todo
0xE0?todo

Tools

  • DRO2MIDI - converts .dro files into .mid files

Similar formats

External links

Personal tools
programming