OPL emulation

From DoomWiki.org

OPL emulation is a feature of some source ports used for playback of MUS and MIDI music.

MIDI music can be seen as sheet music for the computers, contrarily to PCM formats such as WAV which render the same on any compliant platform, MIDI renditions depend on their interpretation by the synthesizer and two different platforms will produce very different outputs.

In the nineties, most home PCs were equipped with Creative Labs Sound Blaster cards, which used the Yamaha "FM Operator Type-L" chips for MIDI synthesis. For many gamers, this chip's sound remains associated to the games of the era, including Doom and its derivatives, however modern computers generally use instead their operating system's software synthesizer, typically relying on a soundfont. The differences in rendering will make it sound "wrong" for people accustomed to the Sound Blaster output.

Note that this is a very subjective domain; OPL rendition of the Doom sound track is not more authentic or accurate. The Doom tracks themselves were composed on a Roland SCC-1, but id Software tried to make sure they would sound as good as possible on the two most popular gaming sound cards of the time, the Sound Blaster and Gravis Ultrasound families, through the GENMIDI and DMXGUS lumps. The variety of available MIDI hardware in the era meant that it was common for games to be issued with several different versions of their soundtracks (Adlib/Sound Blaster, GUS, MT-32, MPU-401, and so on), something which Doom mostly avoided by instead providing these control lumps that would adapt the hardware to the songs. There is, however, one song that has an OPL-specific variant, D_INTRO(A).

OPL chips[edit]

The eight OPL3 waveforms.

The OPL family started with the Yamaha YM3526, which only featured a sine waveform. It was succeeded by the Yamaha YM3812, or OPL2, which added three additional waveform and was used in AdLib and Sound Blaster cards. A cheaper, more limited version known as OPLL (Yamaha YM2413) was derived from the OPL2, but did not find its way to PC soundcards. The Yamaha YMF262 chip, or OPL3, adding four additional waveforms, was the next OPL chip to be used in PC soundcards. Finally, the OPL4 was backward-compatible with the OPL3, but added sample-based synthesis in addition to FM synthesis.

Chip Level FM Channels Output Channels Max Operators Waveforms Notes
Yamaha YM3526 OPL1 9 1 2 1 First in the line
Yamaha YM2413 OPLL 9 1 2 2 Simplified, limited version of OPL2
Yamaha YM3812 OPL2 9 1 2 4 First to be used on PCs
Yamaha YMF262 OPL3 18 4 4 8 Introduced three-point stereo (left, center or right)
Creative CT1747 OPL3 18 2 4 8 Integrated OPL3 core in some Creative Sound Blaster 16 and AWE32 cards; manufactured by Yamaha
Yamaha YMF289 OPL3 18 2 4 8 Low-power version of OPL3, used on some sound cards
Yamaha YMF278 OPL4 18 6 4 8 The FM synthesis is strictly identical to OPL3

Stereo was introduced by dual OPL2 cards. There, one OPL2 core was used for sounds on the left, the other for sounds on the right. Sending instructions to both cores at once resulted in center sounds. The OPL3 core was the first to properly support stereo in the chip itself (though again limited to three panning positions of left, right, and center); but the need for backward compatibility meant that by default, it emulated a mono OPL2 setup, and a specific instruction had to be sent to set it in OPL3 mode proper.

The waveforms available are as follow:

  1. Sine wave, available in all OPL chips.
  2. Half-sine wave, also known as rectified sine wave, available in OPLL, OPL2, and OPL3. The negative parts of the wave are flattened to 0.
  3. Absolute sine wave, available in OPL2 and OPL3. The negative parts of the wave are inverted to be positive.
  4. Quarter sine wave, or halved-half sine wave, or pulse sine wave, available in OPL2 and OPL3. The absolute sine wave, with the downward half of each envelope flattened to 0.
  5. Alternating sine, available in OPL3. The wavelength is halved compared to the normal sine wave, and every alternating period is flattened to 0.
  6. Camel sine wave, available in OPL3. An absolute version of the alternating sine, resulting in pairs of humps grouped together like on the back of a camel.
  7. Square wave, available in OPL3.
  8. Logarithmic sawtooth wave, or derived square wave, available in OPL3. This is actually the result of an exponentiation by a negative number.

Waveforms are then combined either by simple addition of the output of both operators, or by using the waveform from one operator to modulate the phase of the waveform from the second. The FM method is the one that offers the broadest range of possibilities. OPL3 chips can combine two channels to turn them into a single channel with four operators, greatly increasing the possible combinations of addition and frequency modulation available for each sound.

OPL emulators[edit]

A number of OPL emulators exist. Here is a non-exhaustive list:

  • ADLIBEMU: An OPL2 emulator written by Ken Silverman in Watcom C, no longer available though an old version is included in Ken Silverman's RAWPLAY
  • DOSBox OPL: An OPL3 emulator, derived from ADLIBEMU via MAME FMOPL, written in C++ and available under the LGPL
  • DOSBox DBOPL: An OPL3 emulator created by the DOSBox team, successor to the other DOSBox OPL emulator, written in C++ and available under the GPL
  • Emu de MIDI: An OPLL emulator, written in C++ and available under the BSD 3-point license
  • MAME FMOPL: OPL and OPL2 emulator written by Jarek Burczynski and Tatsuyuki Satoh in C++ and available under the GPL
  • MAME YMF262: OPL3 emulator written by Jarek Burczynski in C++ and available under the GPL
  • That Vintage Tone: OPL3 emulator written by Robson Cozendey in Java and available under the LGPL
  • VDMSound: A generic legacy sound hardware emulator, written in C++ and available under the GPL
  • Nuked OPL3: An OPL3 emulator, written by Alexey Khokholov in C and C++ and available under the GPL or LGPL

Music players may integrate one or more of these. For example, AdPlug features both the ADLIBEMU and the MAME FMOPL emulators, while foobar2000's MIDI component includes EMU de MIDI.

Source ports which feature OPL emulation include:

  • Chocolate Doom features the Nuked OPL3 emulator.
  • PrBoom+ features a C port of the DOSBox DBOPL emulator.
  • ZDoom features the MAME FM OPL, the DOSBox OPL, a C++ port of the Vintage Tone and the Nuked OPL3 emulators.
  • 3DGE features the Nuked OPL3 emulator.

External links[edit]