Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Csonicgo

OPL-3 Emulation

Recommended Posts

Recently I've been working on an alternate GENMIDI lump for doom. I've been using Various old-school tools to do this (hex editors, yay), but when I would test in dosbox and then a real OPL-3 chip, the resulting sounds were so different that I had to throw out using dosbox entirely.

Not only did my patches sound completely wrong, none of the subtle phase-shifting I had implemented seemed to work. At all.

http://dl.dropbox.com/u/14696120/adtrack2_000.mp3 this is an emulated OPL-3...

http://dl.dropbox.com/u/14696120/D_RUNNIN.mp3 this is a real one.

Compared to the real output, the emulation is like nails on chalkboard.

What is it about this chip that makes it such a pain to emulate? MOS SID emulators are balls-on accurate these days, but why not this one?

Share this post


Link to post

Calling SID emulator balls-on accurate isn't exactly true though.

I wrote a SID emulator last year. Enough is known about that chip that emulating the digital part of that chip is amazingly simple. Half the chip is analogue though, and thanks to dodgy manufacturing processes each SID chip potentially had a different sound. I think reSID has sampled many of the different SID runs and emulates based on an output profile these days. I don't believe it hits 100% accuracy for any of the manufacturing runs, but gets quite close.

Haven't looked at the OPL-3 much, might do so when I get the time.

Share this post


Link to post

Theoretically you shouldn't be getting any problems when you compare the difference between, say, vanilla and a source port that supports OPL emulation. I don't think you are doing anything wrong. It's just the shitty or out of date OPL emulation library that is being used to play it.

Share this post


Link to post

After doing some snooping on the intertubes, I read that the resulting output is shaped by another Yamaha chip that acts as a filter and a DAC. Most OPL emulators probably do not bother with this step.

Share this post


Link to post
Csonicgo said:

After doing some snooping on the intertubes, I read that the resulting output is shaped by another Yamaha chip that acts as a filter and a DAC. Most OPL emulators probably do not bother with this step.


Not only that, but no sound card on the PC can output 49716 Hz natively, like the OPL2/OPL3 output requires. So of course it will always sound off, even if the OPL itself is emulated perfectly (which IS possible, since it's a 100% direct digital synthesis system, which has even be modeled in VHDL).

In order to accuratly convert such an oddball sampling rate to frequencies that are multiples of 44.1 or 48 KHz like modern sound cards do, you'd need to use intermediate oversample frequencies of 60902100 Hz or 198864000 Hz respectively (yeah, that's 60.9 and 198.86 MHz, just find the LCM of 44.1/48 KHz and the OPL frequency).

No wonder none even bothered with it. Of course, that would require ridiculous processing overhead, and only Creative X-Fi cards have a hardware engine that could plausibly do it without breaking a sweat.

In practice, you will get a crude chopping of the 49716 Hz signal to 44100 or 48000 Hz by simple decimation/sample dropping and that's it, and any post-filtering you can apply will be on an already ruined signal, in most cases.

A practical compromise I had once proposed was to speed up the OPL output to 50 KHz exactly, and thus be able to use an intermediate frequency of "only" 1.2 MHz for 48 KHz final output, for only a 0.5% pitch shift. There may be other similar "magic numbers" to play with (e.g. there's 49600 Hz, with a LCM of 1488000 and only 0.23% pitch variation).

GeckoYamori said:

I don't think there is any OPL3 emulation as of yet. DOSBox only does OPL2.


Many arcade games and the Sega Genesis use a variation of the YM2608 which is very functionally similar to an OPL3, so how hard would it be to find an implementation? (hell, there's even an OPL3 emulator written in Java!)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×