Wohlstand / libOPNMIDI

A Software MIDI Synthesizer library with OPN2 (YM2612) emulator
GNU Lesser General Public License v3.0
96 stars 6 forks source link

Adds the Genesis Plus GX emulator choice #34

Closed jpcima closed 6 years ago

jpcima commented 6 years ago

This is supposed to provide the "ladder" effect distorsion, so it's a thing to test. I scale volume output by half as I believe you do in MAME yourself, to put volume on equal levels with other chips. It's effectively a removal of 1 bit in the quantization of generated sound.

There is a choice of 3 chip types to select in this API. (discrete, integrated, enhanced) I've made enhanced as the default choice, which may or may not be the preferred idea.

This emulator is selected by the flag --emu-gx in opnmidiplay.

Wohlstand commented 6 years ago

By unknown reasons, high notes of toms are not playing at begin of the song, but later same notes are playing fine (xg.wopn bank): Cumbia Arabe_7_echo_chopped_OPN.mid.zip

jpcima commented 6 years ago

It appears plausible that chips beyond the first one are non working for some reason. When the chips count is decreased to 1, some of the percussions are able to play.

Also don't expect the distorsion sound to play, because it's not present under the chip mode selected (needs YM2612_DISCRETE). Under that mode, a background noise makes itself heard.

Wohlstand commented 6 years ago

It appears plausible that chips beyond the first one are non working for some reason. When the chips count is decreased to 1, some of the percussions are able to play.

It's possibly some shared objects (or pointers) are still be shared and wasn't encapsulated into the instance structure... I remembering once I did "multichip"-izing of some another emulator and had similar (or even worse) issue because of this. As we have the proper environment, I would retry to also add that emulator again, even for the purpose to benchmark it in OPL3 Bank Editor.

Wohlstand commented 6 years ago

About of the ladder effect: Nuked OPN2 also supports it, but I have turned it into ASIC mode which means, the chip will have fixed ladder effect bug. As Nukeykt told, YM2612 had a very noisy ladder effect, then discrete had to partially fix it, and ASIC has finally fixed it.

jpcima commented 6 years ago

I don't know what you did to fix the percussion bug at start, I wan't able to debug it myself, but it seems your work has fixed it. :+1:

jpcima commented 6 years ago

With GX there still are issues with skipped notes playing on MIDI keyboard, and it's not at startup only. Is any particular precaution to use with the register interface? may this have to do with similar problems interacting with Nuked you had before? As I remind, Nuked can write register data as buffered. What meaning does this have? has it any link to the problem of GX?

freq-mod commented 6 years ago

Okay, I tested it a little bit:

As I remind, Nuked can write register data as buffered. What meaning does this have? has it any link to the problem of GX?

i wouldn't be surprised if it was the case

jpcima commented 6 years ago

I pushed some work in jpcima:gx-buffer

I just added some simple buffering which forces at minimum one frame of delay between sending commands. This make the notes behave better, resulting in less skipping.

It validates the hypothesis about the lack of writing delays as being source of problems. As next step I should force a larger delay, which will possibly solve the problem altogether. (I noted that Nuked used a fixed delay of 15)

jpcima commented 6 years ago

Here's gx-buffer2 which waits every Nth cycle to send the chip commands. I have not yet heard a problem of skipped notes using this one.

EDIT: but can glitch the drums quite severely Chronologie6_Original_Reworked.zip

Amount of noise is insane, that's good, but I think maybe a macro to choose between discrete and ASIC would be a nice addition

For now edit this line. Change to YM2612_INTEGRATED or YM2612_ENHANCED.

https://github.com/Wohlstand/libOPNMIDI/blob/1b560f917d33b0a48e2fd72a6730f9b885c4bac2/src/chips/gx_opn2.cpp#L11

@Wohlstand how to handle the chip mode, and which to set as the default?

freq-mod commented 6 years ago

What's YM2612_ENHANCED though? How is it different from other modes or real 2612 or 3438?

jpcima commented 6 years ago

YM2612_ENHANCED

It upgrades the quantization of operator outputs from 9 bit resolution to 14.

freq-mod commented 6 years ago

how is it different from integrated ASIC chip (that one also had 14-bit output I heard)? About glitch drums: not only drums are broken, Doom's level 1 BGM has glitchy lead guitars.

jpcima commented 6 years ago

how is it different from integrated ASIC chip (that one also had 14-bit output I heard)?

It gives more resolution not to chip outputs, but internal computations, so increases the computation precision globally (and is free in software to make, since it doesn't cost more processing time).

freq-mod commented 6 years ago

So it's a "fantasy" core which isn't based on any chip/YM2612 derivative that existed in real life?

jpcima commented 6 years ago

The answer is most likely yes. It's the explanation which makes sense to me. The information I know are essentially observations from source code.

Essentially it breaks down like this:

freq-mod commented 6 years ago

I see, thanks. Too bad the emulator depite your hard work seems bugged. Playback is very messy e1m1.zip, and ladder effect is much more louder and prominent in discrete mode than it is on discrete Nuked (try out bank editor)

Wohlstand commented 6 years ago

Nuked at me is works in ASIC mode, so, it has no ladder: only a small distortion caused by the 9-bit PCM output that was post-converted into 16-bits.