Hi All!
Olli Niemitalo just posted this to the music-dsp list. As i am currently a very proud ownder / builder of a midibox-fm (right now the minimum version, next month i’ll start with the “UI”), i just thought some readers of this forum might be interested in his findings. i asked for permission to reproduce his post here, and he agreed. here we go!
Post sent by Olli Niemitalo to music dsp mailinglist 18.4.08:
Me and Matthew Gambrell have an interest in emulation of YM3812, which
is the OPL2 sound chip found in the Adlib and 8-bit Sound Blaster
cards. A later derivative OPL3 is found in early 16-bit Sound
Blasters. We sent one YM3812 and one YMF262 (OPL3) to MEFAS for
decapsulation; the cost was around 90 USD each. They indicated that
the chips would still be operational after decapsulation, but we had
no need to test this. Looking at the revealed YM3812 die surface with
a microscope turned out two ROM’s. See:
http://docs.google.com/Doc?id=dd8kqn9f_13cqjkf4gp
The contents could be read bit-by-bit. The first ROM was a log-sin
waveform table, containing one quarter of a sine wave, 256 samples
long. The second ROM was an exponential table, 256 samples long. There
were no other ROM’s larger than 16 samples. This is strong evidence
that YM3812 produces the sound without any multiplications, using for
frequency modulated (actually phase modulated) synthesis the formula:
out = exp(logsin(phase2 + exp(logsin(phase1) + gain1)) + gain2)
There was first some difficulty understanding the ROM’s because they
were compressed. Every second sample was stored as a difference value
to the previous. Once this was understood, we were able to derive
formulas that met our expectations and re-created the contents of the
ROM tables exactly (yes, they used the same rounding and everything at
Yamaha, back then when they created these tables).
Exponential table:
x = 0..255, y = round((power(2, x/256)-1)*1024)
When such a table is used for calculation of the exponential, the table
is read at the position given by the 8 LSB’s of the input. The value +
1024 (the hidden bit) is then the significand of the floating point output
and the yet unused MSB’s of the input are the exponential of the
floating point output. Indeed, YM3812 sends the audio to the YM3014B
DAC in floating point, so it is quite possible that summing of voices
is done in floating point also.
Log-sin table:
x = 0..255, y = round(-log(sin((x+0.5)*pi/256/2))/log(2)*256)
This is the first (rising) quarter of sine wave. The rest can be
constructed by flipping all the bits of x and/or by changing the sign
of the samples.
I hope this will be useful for anyone writing a good emulator. Also,
there are no extra ROM’s on the YMF262 (OPL3), so the additional
waveform is probably simply the exponential table.
-olli