Yamaha YMF262 (OPL3) emulator

This is an OPL3/OPL2 emulator.
The OPL3 and OPL2 chips were widely used in game music from the late 80's and early 90's, through the Adlib and Sound Blaster sound cards.
This emulator reproduces these sounds, and here we have an Applet to demonstrate the use of it, and in the meantime to have some fun:

If the applet does not appear, you may not have Java installed, or you may have an old version of it, prior to version 6. You can install Java's latest version by cliking here.

Further information and source code

One of the objectives of this emulator is to stimulate further research in the OPL3 chip emulation. This emulator's main body of information was taken from reverse engineering of the OPL3 chip, from the YMF262 Datasheet and from the OPL3 section in the YMF278b Application's Manual, both available in SoundProgramming.net, together with the vibrato table information, eighth waveform parameter information and feedback information provided in MAME's YMF262 and YM3812 emulators.
The emulator has a high degree of accuracy, and most of music files sound almost identical, exception made in some games which uses specific parts of the rhythm section.

This emulator source code is available through the GNU Lesser General Public License (LGPL), and you can download it here:

opl3_v1.0.6.zip

Note: The player Applet used in this page is to demonstrate the functioning of the emulator only.
The .laa and .cmf part of the player Applet uses code from the Adplug project files mid.cpp, mid.h, and mididata.h by Philip Hassey and Simon Peter. This derived library is available under LGPL, the same license of AdPlug, and you can download it here.
The .laa and .cmf example files used in this applet were taken from the melcom's ChipTune Archive

The emulator was made through the reverse engineering of the OPL3 chip using an old AMD K6-2 500Mhz computer with a Sound Blaster 16 installed in it.

After doing the initial implementation of the emulator, I did a complete re-write, testing each aspect against the real SB16 output.


This was done through doing test methods written in Java in a Windows XP machine,
and doing the same test methods written in C++, running on DOS in the SB16 machine.

Both outputs were recorded. After that, the emulator audio output was played in the SB16 computer, to allow it to pass by the same SB16 DAC and ensure the distortions would end up the same.

Then the three waves were compared, and when necessary revisions of the code were made.
In the image at right we can see the three waves. The topmost wave is the emulator output, the second is the emulator through the SB16 DAC output, and the last one is the real OPL3 output.

And finally, the real-world tests. I made a java replayer, based on the Adplug suite, that could play game music in CMF, LAA, and DRO formats, and checked some side-effects that they used when writing for the OPL3.

There were some interesting trivia that I discovered. The guys at LucasArts, for most of their games, don't like the OPL2/3 rhythm mode at all.
(I guess the rhythm section is so badly documented, that even them didn't like to use it.)
The drums in the great majority of their games were made using enveloped noise, that they could get through high MULT and FB rates, no rhythm mode.

The guys that wrote for the Creative Music File format, in the files that I tested, was a bit tougher.
In the files in the Example menu, they do use a lot of the rhythm mode, and distortion through high MULT rates, together with some others few side-effects. In this respect, some parts of the rhythm mode are still only an approximation of the real chip.
The other thing to note is that this emulator was done through recordings of the SB16 DAC, so it has not bitwise precision. Additional equipment should be used to verify the samples directly from the chip, and allow this exact per-sample correspondence. As a good side-effect, since this emulator uses floating point and has a more fine-grained envelope generator, it can produce sometimes a crystal-clear, denser kind of OPL3 sound.

Copyright (c) 2008 Robson Cozendey