Wohlstand / libOPNMIDI

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

Correct internal sample rate (MAME core) #26

Closed freq-mod closed 6 years ago

freq-mod commented 6 years ago

As I reported (Wohlstand/OPN2BankEditor#7), turns out that internal sample rate doesn't match YM2612's real sample rate (53267 Hz?). Therefore many instruments such as hi-hats, cymbals, triangles, etc don't sound as they should.

Wohlstand commented 6 years ago

The thing I must to make is processing emulation in 53267 Hz, but resample the output into 44100 hz as requested on initialization of the emulator. But thanks for noting the internal sample rate value now I finally know :wink:

freq-mod commented 6 years ago

But thanks for noting the internal sample rate value now I finally know

I took it from this thread: https://forums.nesdev.com/viewtopic.php?f=23&t=12772 I'm not as familiar with OPN2 as I'm with OPNA; which I know has 55466 Hz sample rate :wink:

Wohlstand commented 6 years ago

Just now I made a small test: I have installed in my VLC properties to output OPNMIDI with 53267 hz, and sounding of my ride cymbals in a same MIDI file now is matching Nuked OPN2!

Wohlstand commented 6 years ago

@jpcima , as you just now have made the improved resampler on Nuked OPL3, it's also needed to be made here too, BUT, also, implement the simple resampler that will be used by default. It's need to output from MAME the 53267 hz, but do post-resampling. Then, emulator will almost-match by sounding with Nuked OPN2 and real chip.

jpcima commented 6 years ago

Yeah let's do it. For the normal case i'll copy-paste linear resampling code of Nuked OPN in fixed point integers.

EDIT Nuked OPN does not have a well separate resampling like there is in its OPL3 friend. I should rearrange this at some point later.

jpcima commented 6 years ago

It's not all that straight-forward because MAME is not possible to drive by single frame generation. An attempt to do that is likely to make the processing cost go through the roof. So, it is obligatory to introduce an intermediate buffering, and ideally a computation to know in advance how much frames to feed in the input to obtain N frames of output. And that with zita resampling, I don't know of a full reliable way to determine it.

Wohlstand commented 6 years ago

MAME now does native sample rate! :fox_face: :+1: So, next stuff is optional HQ Zita Re-sampler work from @jpcima which he recently made into libADLMIDI :wink:

jpcima commented 6 years ago

Do you consider the drums to be now fixed? It's a note to myself, I should also also add the resampling option to Nuked like it was done in ADLMIDI.

freq-mod commented 6 years ago

Just checked out, it's alright now. Thanks to both of you! P.S.: about zita-resampler library; is there a windows version/build of that?

Wohlstand commented 6 years ago

I think, it's can be easily built on MinGW since I have inspected the tarball with the resampler here: http://kokkinizita.linuxaudio.org/linuxaudio/downloads/zita-resampler-1.6.0.tar.bz2 I'll try to research the ability to build it on MinGW at my home. The only in the code is in use is PThreads thing which is available on MinGW but not on MSVC except of some ports or possible wrappers...

jpcima commented 6 years ago

Yes building on MinGW is a triviality, but there isn't a ready build system for it in the source archive. Also, I think Fons Adriaensen is no longer active on his projects, so one of us can fork this and make a build system for Windows, and release a set of binaries.

Wohlstand commented 6 years ago

That probably can be made via CMake, and yeah, I'll even can make the repo and put zita-resampler into it with the CMake builder

Wohlstand commented 6 years ago

I'll close this as the task has been completed and confirmed! I'll copy the work over chips into OPN2 Bank Editor when I'll be at my home...

Wohlstand commented 6 years ago

Oh, I wasn't closed it by mistake on a button... But okay that you did that by yourself :wink:

jpcima commented 6 years ago

@Wohlstand I did the Zita-resampler work so you just have to pull this in your repo. The Pthread requirement was also removed so MSVC should be able to build. https://github.com/jpcima/zita-resampler

freq-mod commented 6 years ago

Turns out it's not so trivial: fail

Wohlstand commented 6 years ago

@papiezak, std::mutex needs for C++11 turned on. The CMake config @jpcima made uses the default behavior of given compiler as you can see.

jpcima commented 6 years ago

Pull the very latest

freq-mod commented 6 years ago

still pretty much the same

jpcima commented 6 years ago

Ok I'm going to backpedal and implement another strategy. I don't need c++11.

jpcima commented 6 years ago

I've rewritten master with a version which is normally c++98 compatible. I can build it.

freq-mod commented 6 years ago

thanks @jpcima, pulled the very latest, now it compiles