MDI Format

From ModdingWiki
Jump to navigation Jump to search
MDI Format
Format typeMusic
Notation typeMIDI
Max channel count9 or 11
Max track count65535
Max pattern count1
Max order count0
Tags?Text events

The MDI Format is derived from ROL Format and have compatible specification for playback. It uses a standard MIDI file structure (MIDI Type 0) that contains MIDI meta events for setting OPL instrument settings. It is a way of storing FM/OPL instruments inside a standard MIDI file, with the file being a standard, fully compatible .mid file. Players that are not aware of the FM/OPL commands will simply ignore them and play the file without instruments.

Typically standard MIDI files use the .mid filename extension, while files that use the FM/OPL commands are given the .mdi extension.

Differences to standard MIDI

Manufacturer-specific events

To be compatible with standard MIDI container specification, the format uses sequencer specific events to change instrument patches, control AdLib rhythm mode, and set pitch bend range.

These meta events begins with 0xFF byte, followed by 0x7F parameter, indicating "sequencer specific" event. Then it's followed by variable length value and the data blob.

The first data byte is a manufacturer ID. If it is 0x00, then the following UINT16BE is the actual manufacturer ID. This means either one or three bytes total will be read to obtain the manufacturer ID.

If the manufacturer ID is 0x3F then it is an Ad Lib, Inc. event. In this case, read another UINT16BE to obtain the opcode, then the data following the opcode is arranged as:

Opcode Purpose Description
1 Instrument change 29 data bytes follow:
UINT8voiceMIDI channel number to assign instrument to
BNK_ENTRYpatchOPL register settings
2 Sound mode One data byte. 0=melodic/rhythm-off, 1=percussive/rhythm-on
3 Pitch bend range One data byte, value in range 1-12 inclusive. ! Explain how this works

BNK_ENTRY is defined as follows: (note this is identical to the layout of an instrument inside a AdLib Instrument Bank Format .bnk file. See that article for the explanation of the OPLREGS structure.)

Data type Name Description
OPLREGS oplModulator Register values for the Modulator operator (op 0)
OPLREGS oplCarrier Register values for the Carrier operator (op 1)
UINT8 iModWaveSel Modulator wave select (OPL base register 0xE0)
UINT8 iCarWaveSel Carrier wave select (OPL base register 0xE0)

Channel aftertouch event

Event 0xD# is used to control channel volume. It mostly used for dynamic volume control of currently played note (for example: fade in, fade out, or tremolo effects).

Velocity parameter

This parameter goes with Note On and Note Off events. Since the format is inherited from ROL, it doesn't have note velocity specification.

It also changes current channel volume, same as event previously described.

Some "Note Off" events may have note parameter equal to 0. This event just stops last played note on specified channel. If there is no played note on channel, it obviously used to set channel volume.


The following tools are able to work with files in this format.

Name PlatformPlay? Create new? Modify? Convert/export to other? Import from other? Access hidden data? Edit metadata? Notes
AdLib midiplay.exe DOSYesNoNoNoNoNoNo Part of AdLib Programmer's Guide
AdLib rol2midi.exe DOSNoNoNoNoYes; .rolNoNo Part of AdLib Programmer's Guide
Camoto Linux/WinYesNoNoYes; manyNoNoYes

See also