OPL emulation

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 formats such as  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  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, typically relying on a. 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, 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 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
The OPL family started with the, which only featured a sine waveform. It was succeeded by the, or OPL2, which added three additional waveform and was used in and  cards. A cheaper, more limited version known as OPLL was derived from the OPL2, but did not find its way to PC soundcards. The 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.

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 dual 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 frequency 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
A number of OPL emulators exist. Here is a non-exhaustive list:
 * ADLIBEMU: An OPL2 emulator written by 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: OPL3 emulator written by Jarek Burczynski in C and available under MAME's open-source, non-commercial license
 * That Vintage Tone: OPL3 emulator written by Robson Cozendey in Java and available under the LGPL
 * : A generic legacy sound hardware emulator, written in C++ and available under the GPL

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

Source ports which feature OPL emulation include:
 * Chocolate Doom features a C port of the DOSBox DBOPL emulator.
 * PrBoom+ features the Chocolate Doom version of the DBOPL emulator.
 * ZDoom features the MAME FM OPL, the DOSBox OPL, and a C++ port of the Vintage Tone emulators.