The lump is a database of OPL register values, used to program the OPL chip found in the AdLib and Sound Blaster sound cards. It contains 175 entries, one for each of the 128 standard General MIDI instruments and 47 percussion effects.
Instruments settings that were shipped with the DMX library were made by Scott Host of Cygnus Studios using the stock General MIDI settings from AdLib Inc. as a starting point. Then id Software and Rogue Entertainment made their own tweaks to these settings.
Doom and Doom II have different GENMIDI lumps, but Final Doom reuses the Doom II set, resulting in a different sound for the Doom tracks used in Plutonia. Heretic, Hexen, and the Strife demo, on the other hand, use the standard DMX set. The retail version of Strife provides its own set, derived from the Doom II set.
The lump has an 8-byte ASCII header, containing the text "#OPL_II#".
The header is followed by 175 36-byte records of instrument data.
Each record has a 4 byte header of the following form:
|0||2||Flags (see below). Little endian.|
|2||1||Fine tuning - This normally has a value of 128, but can be adjusted to adjust the tuning of the instrument. This field only applies to the second voice of double-voice instruments; for single voice instruments it has no effect. The offset values are similar to MIDI pitch bends; for example, a value of 82 (hex) in this field is equivalent to a MIDI pitch bend of +256.|
|3||1||Note number used for fixed pitch instruments (see below)|
The flags value is a bitfield containing several flags that control the record. These are:
|0||0x0001||Fixed pitch - Instrument always plays the same note. Most MIDI instruments play a note that is specified in the MIDI "key on" event, but some (most notably percussion instruments) always play the same fixed note.|
|1||0x0002||Unknown - used in instrument #65 (Alto Sax) of the Doom GENMIDI lump, though unused even in DMX itself.|
|2||0x0004||Double voice - Play two voices simultaneously. This is used even on an OPL2 chip. If this is not set, only the first voice is played. If it is set, the fine tuning field (see above) can be used to adjust the pitch of the second voice relative to the first.|
Following the header are two 16 byte records of OPL voice data. If the double voice bit is set in the header, both voices will be played simultaneously; otherwise, only the first set of voice data is played.
The voice data has this format:
|0||1||Modulator Tremolo / vibrato / sustain / KSR / multi|
|1||1||Modulator Attack rate / decay rate|
|2||1||Modulator Sustain level / release rate|
|3||1||Modulator Waveform select|
|4||1||Modulator Key scale level|
|5||1||Modulator Output level|
|7||1||Carrier Tremolo / vibrato / sustain / KSR / multi|
|8||1||Carrier Attack rate / decay rate|
|9||1||Carrier Sustain level / release rate|
|10||1||Carrier Waveform select|
|11||1||Carrier Key scale level|
|12||1||Carrier Output level|
|14||2||Base note offset. This is used to offset the MIDI note values. Several of the GENMIDI instruments have a base note offset of -12, causing all notes to be offset down by one octave.|
This data is essentially the same as the data found in Soundblaster SBI files; the differences are that the data is ordered differently, and the key scale and output level fields are split into two separate bytes within GENMIDI. In the SBI format, they are combined as bitfields within a single byte. For this reason, and because of the extra unused fields, the GENMIDI instrument data is longer (16 bytes) than SBI data (11 bytes).
Following the instrument data is 175 32-byte ASCII fields containing the names of the standard General MIDI instruments. It is not clear how these names are used within the sound code, if at all.
All stock GENMIDI Instruments are designed to play on OPL2, so none of the OPL3 waveforms are ever used. However, DMX supports the additional 4 waveforms provided by the OPL3 chip, provided that DMX is set to OPL3 mode.
Quirks and limitations
- When a double voice instrument is played, both voices' carrier waves will play as if they have the same volume level, which is determined by the first voice.
- Voices in AM mode may exhibit issues when feedback is used.
- The octave range is narrower than what the OPL chip allows. Notes under or over a certain octave threshold will "fold back", or repeat the notes from the lowest or highest octave.
Use in modern ports
Most modern operating systems do not provide the ability to program the OPL chip directly; indeed, most modern computers do not even contain OPL-compatible sound chips. It is therefore common for source ports to simply use the standard MIDI playback API, and the GENMIDI lump is not used. There are a few source ports which do use the GENMIDI lump; particularly as it is necessary when performing OPL emulation. Ports with GENMIDI support include Chocolate Doom and ZDoom.
- The Stock DMX, Doom and Doom II GENMIDI lumps contain some percussion instruments that were once defined, but intentionally silenced. These include the Short and Long Whistle, the Short and Long Guiro, and the Mute and Open Cuica.
- There exist instruments in the Doom GENMIDI lump with defined second voices, but the double voice flag is disabled.
- Some instruments have an asterisk before the instrument names. This is likely left over from development to indicate a pasted duplicate of an existing instrument.
- Instrument 88, listed as "Pad 1 (new age)" in the GM standard, is misnamed as "* Lead 8 (bass & lead)". It is also a direct copy of Instrument 87, listed as "Lead 8 (bass & lead)". This is clearly a mistake, given that these two instruments are located next to each other in the instrument listing.
- The most notable GENMIDI voices differing between Doom and Doom II are the Overdriven Guitar, Fretless Bass, and Acoustic Bass. The Acoustic Bass in Doom was an octave higher than intended, which was fixed in Doom II. The Fretless Bass changes were likely for aesthetics, given that Fretless Bass was used a lot more in Doom II music. The Overdriven Guitar in Doom II is a slight modification of the Distortion Guitar from Doom.