AdLib Instrument Format
The AdLib Instrument Format was the original format developed by Ad Lib, Inc. in 1987 to store OPL instruments in individual files with the .ins extension. It went through a number of revisions as hardware capabilities were added to the OPL chip, but ultimately it was replaced by the AdLib Instrument Bank Format, which combined multiple instruments into a single file with a .bnk extension.
For a short time before the BNK format was introduced, there was an early bank format called AdLib Timbre Bank Format which used a .snd or .tim extension. Each instrument in this bank format is stored in a structure almost identical to the structure used in the individual .ins instrument files.
The file is in the following structure:
|UINT16LE||unknown||Unknown purpose, always 0x0000|
|OPLREGS||oplModulator||Register values for the Modulator (0) operator|
|OPLREGS||oplCarrier||Register values for the Carrier (1) operator|
|UINT16LE||iModWaveSel||Modulator wave select (only bits 0-1 recognised, OPL register 0xE0)|
|UINT16LE||iCarWaveSel||Carrier wave select (only bits 0-1 recognised, OPL register 0xE0)|
|char||unknown2||Unknown purpose reserved space. Second to last byte usually always 0x01 or 0x00|
The last three fields (iModWaveSel, iCarWaveSel, unknown2) are not present in early 54-byte files in this format. Some files are also missing oplCarrier entirely - presumably these are patches for single-operator percussive instruments. Possibly unknown2 is an instrument name, but the existing software doesn't use it and uses the base filename instead.
The OPLREGS structure is defined as:
|Data type||Name||Description||OPL base register||Value range|
|UINT16LE||iKSL||Key scaling level||0x40 (bits 6-7)|
|UINT16LE||iMultiple||Frequency multiplier||0x20 (bits 0-3)||iMultiple & 0x0F is sent to OPL register [verify this]|
|UINT16LE||iFeedback||Feedback||0xC0 (bits 1-3)||Although only bits 1-3 are valid, Vinyl doesn't limit the output to three bits wide.|
|UINT16LE||iAttack||Attack rate||0x60 (upper four bits)||[verify this]|
|UINT16LE||iSustain||Sustain level||0x80 (upper four bits)||[verify this]|
|UINT16LE||iEG||Envelope gain (nonzero value is on)||0x20 (bit 5)||[verify this]|
|UINT16LE||iDecay||Decay rate||0x60 (lower four bits)||[verify this]|
|UINT16LE||iReleaseRate||Release rate||0x80 (lower four bits)||[verify this]|
|UINT16LE||iTotalLevel||Total output level||0x40 (bit 0-5)||[verify this]|
|UINT16LE||iAM||Amplitude modulation (Tremolo)||0x20 (bit 7)||[verify this]|
|UINT16LE||iVIB||Frequency Vibrato||0x20 (bit 6)||[verify this]|
|UINT16LE||iKSR||Key scaling/envelope rate||0x20 (bit 4)||[verify this]|
|UINT16LE||iCONoff||Connector [OP0 only]||0xC0 (bit 0, inverted)|| 0: OPL bit set to 1|
other: OPL bit set to 0
There is apparently no distinction between percussive and melodic instruments. This is controlled at playback time, depending on which channel the instrument is loaded into.
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 bankmng.exe||DOS||No||Yes||Yes||Yes; .bnk||Yes; .bnk||No||No||Part of AdLib Programmer's Manual|
|Camoto||Linux/Win||No||No||No||Yes; many||Yes; many||No||Yes|
|OPL3 Bank Editor||Linux, Windows, macOS||Yes||Yes||Yes||Yes; many||Yes; many||No||Yes|
This file format was documented by Malvineous from reading code included with the AdLib Programmer's Manual. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)