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
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:
|1||Instrument change||29 data bytes follow:|
|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.)
|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).
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||Platform||Play?||Create new?||Modify?||Convert/export to other?||Import from other?||Access hidden data?||Edit metadata?||Notes|
|AdLib midiplay.exe||DOS||Yes||No||No||No||No||No||No||Part of AdLib Programmer's Guide|
|AdLib rol2midi.exe||DOS||No||No||No||No||Yes; .rol||No||No||Part of AdLib Programmer's Guide|
- MID Format - the container format
- AdLib Instrument Bank Format - format with the same instrument definition structure
- http://cd.textfiles.com/soundsensations/MISCPROG/ZIPFILES/AD-PROG.ZIP - AdLib Programmer's Guide, including source code for playing and converting files in this format