Nuked OPL3 emulator

Emulation of old PCs, PC hardware, or PC peripherals.

Nuked OPL3 emulator

Postby nukeykt » 2013-12-26 @ 03:39

Nuked OPL3 emulator

Features:
-Very accurate. IMHO it is most accurate emulator at this time.
-Easy to integrate to any C/C++ project.
-Integrated linear resampler, though i recommend to use better resampler since linear produces some artefacts.

My emulator already present in these projects:
-Doom source ports: ZDoom, GZDoom, Chocolate Doom(dev builds), Crispy Doom, 3DGE(2.1.0 test builds)
-Windows OPL3 user mode drivers.
-Adlib Tracker II SDL(ported to pascal)
-AdPlug

Comparison with real YMF262:
https://www.youtube.com/watch?v=6qXMIm4eSCc

Code:
https://github.com/chocolate-doom/choco ... opl/opl3.c
https://github.com/chocolate-doom/choco ... opl/opl3.h
Last edited by nukeykt on 2016-9-18 @ 14:02, edited 11 times in total.
nukeykt
Newbie
 
Posts: 97
Joined: 2013-8-28 @ 11:11
Location: Russia

Re: OPL3 emulator

Postby leileilol » 2013-12-27 @ 15:43

Noticed there's no vibrato.
Voodoo2s aren't 100mhz stock
Geforce256 isn't released as a beta on New Years '99 under the Quadro brand
386DX vs SX isn't about a missing FPU
DOS gaming isn't a bilinear 320x200 16:10
DOS PCs aren't better than the Macintosh
Old PCs aren't 'aesthetic'
User avatar
leileilol
l33t++
 
Posts: 9050
Joined: 2006-12-16 @ 18:03

Re: OPL3 emulator

Postby MaliceX » 2014-1-11 @ 11:51

This is good. Not only the codebase is smaller, it doesn't use floating point (save for the OPLRATE preprocessor define) arithmetic at all, and the upper registers sound louder/clearer.

Do you mind if I add this to the forked driver as a possible alternative emulator core?
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby MaliceX » 2014-1-12 @ 08:39

By the way, it looks like there is a bug with how key ons should be treated with operators whose output levels have reached silence on the envelope. On real chips (YMF724F-V, CMI8738, ESS ESFM, FM801), AdlibEmu/DOSBOX core, and Jarek's MAME core, key-ons for channels where Key Off has not been received do not reset the silent operator's EG.

With your core, Key Ons on voices will reset the envelopes of operators that have reached silent level, but has not been set to OFF state. Do not assume operators reaching silence means the operator EG is OFF as this is only determined after a key-off command. This is necessary for some game music (eg: Tyrian, Rusty, Mad Paradox) where songs have pitch sweeps on percussive patches.
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby Jepael » 2014-1-13 @ 08:10

There is definitely potential, but somewhat off from the details provided by the submarine forum.

For instance the waveforms are a bit off. When output is said to be zero, it is really attenuated so that PCM output is zero, not logsin[0] which is 12 in PCM.
And the square wave should be +/- max output, so the attenuation should be 0 with either +/- sign, not index/4 with +/- sign.

I also don't get the EG reset. At any point the key-on goes from 0 to 1, EG will start the attack phase, but from whatever previous volume, which is not zero if the sound was decaying/releasing.
Same with release, at any point the key-on goes from 1 to 0, the EG will start the release phase, even if it did not fully attack/release. I think. I have not verified this.
Jepael
Oldbie
 
Posts: 1195
Joined: 2005-6-15 @ 19:28
Location: Finland

Re: OPL3 emulator

Postby MaliceX » 2014-1-13 @ 14:37

Jepael wrote:I also don't get the EG reset. At any point the key-on goes from 0 to 1, EG will start the attack phase, but from whatever previous volume, which is not zero if the sound was decaying/releasing.
Same with release, at any point the key-on goes from 1 to 0, the EG will start the release phase, even if it did not fully attack/release. I think. I have not verified this.

This is actually correct behaviour what you're describing. It exhibits features which benefit mono-legato voice playback support (which I'm using to support in my MIDI driver fork). This is also very common with other FM chips, to continue from previous voices on next key on, following from their current position on a channel's assigned envelope.

http://djtbmx.jamesoz.com/junk/opl3vgmlog-egbug.zip

The bug I'm describing however, is where this fails. I've attached a zip which contains the following files:

opl3test-egbug - Two drum notes both with falling pitch being demonstrated via Fnum+keyons without a key off
opl3test-egbug2 - A fast-attack marimba patch playing a single sustained chord for a few bars, with fnum+keyons for software-driven vibrato

Each of the above tests come with the following:
  • vgm file = playable (via in_vgm/VGMPlay/foo_gep) register log of YMF262 commands being received. (these are just two MIDI notes being played, whose notes/patches have a software pitch envelope attached to them to attain that 'falling' pitch sound)
  • txt file = text-readable representation of the above file (used vgm2txt)
  • cmi8738output wav = output of the above, using my CMI8738. The long silence is intentional since these are long-held notes, to let the driver spam f-num data to the chip as observed in their txt.
  • khokh2001output wav = output of the above, using khokh2001's emulated core. Note the intermittent attacks that follow, suggesting reset envelopes on key on without a key off between.
The YMF724F-V matches the behaviour of the CMI8738 recording, as do Jarek's MAME and DOSBOX ADLIBEMU cores. If anyone with a real SB16 could play the .vgm log through VGMPlay via OPL passthrough, you can check if this happens with your hardware too (however I am confident this will result in confirming my findings anyway)
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby MaliceX » 2014-1-25 @ 13:26

OK. Fixed the retrigger bug.
opl->OPs[op].key was never used, so I used it to indicate key on/off, where on = 1, off = 0

Here's the fixed .cpp attached.

EDIT: Not sure if it's a bug, but it seems like voices that are meant to be silent, you can still hear them at a very faint volume. Is this intentional?
Attachments
opl3.cpp
Fixed EG_OFF / EG_RELEASE state where key off was not received, causing unwanted retriggers on next key on commands.
(29.02 KiB) Downloaded 114 times
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby Jepael » 2014-1-25 @ 19:54

MaliceX wrote:EDIT: Not sure if it's a bug, but it seems like voices that are meant to be silent, you can still hear them at a very faint volume. Is this intentional?


Silent, in what situation? Regarding midi data or OPL emulation side? If a sound is in release phase, and the release rate is larger than 0 so that it will actually release, the sound level will go below audible levels. In fact the output will be either 0 or -1 depending on waveform sign being positive or negative.
Jepael
Oldbie
 
Posts: 1195
Joined: 2005-6-15 @ 19:28
Location: Finland

Re: OPL3 emulator

Postby jwt27 » 2014-1-25 @ 20:22

Maximum value for the attenuation register is 0x3F or -47.25dB. That is very quiet but not silent.
WANTED - Manuals/drivers for:
  • Tecmar Graphics Master
  • Paradise Autoswitch EGA 350 (EGA1A)
User avatar
jwt27
Oldbie
 
Posts: 1628
Joined: 2011-8-15 @ 02:19
Location: Fryslân

Re: OPL3 emulator

Postby MaliceX » 2014-1-25 @ 23:42

jwt27 wrote:Maximum value for the attenuation register is 0x3F or -47.25dB. That is very quiet but not silent.

Yup. Confirmed this behaviour with my YMF724 card. Thanks.
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby nukeykt » 2014-3-14 @ 06:34

Small update released
nukeykt
Newbie
 
Posts: 97
Joined: 2013-8-28 @ 11:11
Location: Russia

Re: OPL3 emulator

Postby MaliceX » 2014-3-31 @ 13:37

I can see you've taken a different approach for the EG fix. Cool stuff.
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby chipko » 2014-9-03 @ 00:33

Hi to everyone, I read you for a while, you're good.
Unfortunately my knowledge is barely enough to follow you and to understand you, even if you are very clear.
I was wondering if the above oplemu created by khokh2001 (this is the same person of Chocolate Doom?) Could be installed or used on dosbox.
If so how do you do it?
I hope my question is not too stupid.
Thanks in advance.
chipko
Newbie
 
Posts: 3
Joined: 2014-9-03 @ 00:20

Re: OPL3 emulator

Postby leileilol » 2014-9-03 @ 05:10

Chocolate Doom was done by fraggle.
Voodoo2s aren't 100mhz stock
Geforce256 isn't released as a beta on New Years '99 under the Quadro brand
386DX vs SX isn't about a missing FPU
DOS gaming isn't a bilinear 320x200 16:10
DOS PCs aren't better than the Macintosh
Old PCs aren't 'aesthetic'
User avatar
leileilol
l33t++
 
Posts: 9050
Joined: 2006-12-16 @ 18:03

Re: OPL3 emulator

Postby chipko » 2014-9-04 @ 13:19

Ok, thank you. I had been deceived by the similarity of the letters.
Anyway I would like to know if it was possible to install the khokh2001's oplemu in dosbox. Is it better than version already present?
chipko
Newbie
 
Posts: 3
Joined: 2014-9-03 @ 00:20

Re: OPL3 emulator

Postby MaliceX » 2014-10-12 @ 10:37

khokh2001's core is all integer arithmetic, however it still has a few minor bugs in the emulation output (particularly for more complex/highly modulated waveforms). The core used in DOSBox is still more accurate, as far as comparing to genuine Yamaha OPL3 output goes. :)
User avatar
MaliceX
Newbie
 
Posts: 86
Joined: 2004-10-03 @ 05:03
Location: Australia, VIC

Re: OPL3 emulator

Postby chipko » 2014-10-24 @ 00:45

MaliceX wrote:khokh2001's core is all integer arithmetic, however it still has a few minor bugs in the emulation output (particularly for more complex/highly modulated waveforms). The core used in DOSBox is still more accurate, as far as comparing to genuine Yamaha OPL3 output goes. :)

Thank you for answering me.
chipko
Newbie
 
Posts: 3
Joined: 2014-9-03 @ 00:20

Re: Nuked OPL3 emulator

Postby nukeykt » 2016-5-12 @ 14:39

Bump...
nukeykt
Newbie
 
Posts: 97
Joined: 2013-8-28 @ 11:11
Location: Russia

Re: OPL3 emulator

Postby leileilol » 2016-5-12 @ 21:19

chipko wrote:Ok, thank you. I had been deceived by the similarity of the letters.

Well almost 2 years later, Chocolate Doom has his core in the repository now. :)
Voodoo2s aren't 100mhz stock
Geforce256 isn't released as a beta on New Years '99 under the Quadro brand
386DX vs SX isn't about a missing FPU
DOS gaming isn't a bilinear 320x200 16:10
DOS PCs aren't better than the Macintosh
Old PCs aren't 'aesthetic'
User avatar
leileilol
l33t++
 
Posts: 9050
Joined: 2006-12-16 @ 18:03

Re: Nuked OPL3 emulator

Postby Stretch » 2016-5-13 @ 11:14

Does Nuked OPL3 emu have a rockbox port? Would it be faster than dosbox or MAME OPL on portable audio players?
Win98SE - Intel SE440BX-2 - Pentium II 233 Mhz - 256 MB System Ram - Voodoo 3 1000 AGP - Yamaha YMF-724 PCI - Soundblaster 32 ISA
Stretch
Member
 
Posts: 271
Joined: 2013-11-16 @ 00:57

Next

Return to PC Emulation

Who is online

Users browsing this forum: ss2201965 and 2 guests