SDL-Mixer-X icon indicating copy to clipboard operation
SDL-Mixer-X copied to clipboard

One GME issue on SPC

Open Yave-Yu opened this issue 2 years ago • 13 comments

Idea no Hi's title screen music (01 Day of the Idea) on SDL Mixer X has unpleasure audio bursting (?) effect, but other place of GME such as kode54's GME plugin for FB2K didn't has this issue.

Yave-Yu avatar Aug 03 '22 11:08 Yave-Yu

At MixerX the mainstream GME is used: https://bitbucket.org/mpyne/game-music-emu/wiki/Home However, I do some updates on GME itself sometimes. Also, @kode54 developed an updated patch over the latest mainstream. I ported almost all his updates to the mainstream, except for the SPC update which has a serious problem of tempo changing which I hadn't resolved yet.

unpleasure audio bursting (?) effect

Try the Moondust MusPlay and ensure the F32 format is used for output. Anyway, at SMBX38A, please specify the |0;g=1.0; gaining factor to make sure this file won't be too loud.

I tried to listen to the song at ZXTune (which uses old kode54's modded GME) and Moondust MusPlay to verify the sounding, and I can't understand, what the problem is... Could you record a small fragment of "what should be" and "what actually happens"?

Wohlstand avatar Aug 03 '22 11:08 Wohlstand

The problem with SMBX-38A is that it still requests to run the S16 audio format, and it really needed to switch the F32 format output (I already did that on TheXTech and Moondust Project) to avoid possible clipping when too loud output.

Wohlstand avatar Aug 03 '22 11:08 Wohlstand

ShortCompare.zip One is FB2K GME plugin, another is SDL Mixer X (Music player, F32LSB). Just the song's intro clip. 爆电平

Yave-Yu avatar Aug 04 '22 05:08 Yave-Yu

I hear the difference of timbre between two of variants :thinking:

Wohlstand avatar Aug 04 '22 15:08 Wohlstand

Anyway, I'll ask for more info from @kode54 what the real difference between the old blaarg's SPC emulator and the new one that he used later...

Wohlstand avatar Aug 04 '22 23:08 Wohlstand

Try toggling the SPC analog simulation filter in Advanced Preferences in foobar2000. GME defaults this filter to enabled, I was suggested by users to disable it by default. If this is indeed the cause, it is already proposed to add an option to toggle it at runtime here.

kode54 avatar Aug 05 '22 00:08 kode54

This filter, along with gaussian interpolation, is intended to simulate what a hardware unit would sound like. The gaussian interpolation table is hardware correct to produce exact digital output, while the analog filter stage is supposed to mimic the behavior of the analog components post-DAC.

kode54 avatar Aug 05 '22 00:08 kode54

FB2K GME allows to choose different interpolation! SDL Mixer X can only by played via gaussian!

LoveBodhi avatar Aug 10 '22 03:08 LoveBodhi

FB2K GME also uses a different fork of GME that has different interpolation modes added, just because it was simple enough to add them. I chose to implement the interpolation setting as a signed integer where 0 is gaussian, going up from there is mathematically higher quality than hardware, such as cubic interpolation and 8 point sinc interpolation, while going lower than 0 is linear interpolation and no interpolation, which just sounds horrid in many cases.

Unlike sample rate scaling, it was something I could implement easily. Sample rate changes would require scaling all envelope parameters, as well as all echo/reverb parameters, which is not so easy to do in a linear fashion, especially considering FIR coefficients.

kode54 avatar Aug 10 '22 04:08 kode54

I took some investigation, and I found the option called gme_enable_accuracy() which disables/enables the filter (SPC_Filter), and now I am really curious, should it help with the issue? :thinking:

I made the recording to compare with the enabled or disabled option (by default it's enabled).

https://user-images.githubusercontent.com/6751442/185275945-dd93645d-8b1c-440f-9ddf-63e0279ad997.mp4

@Yave-Yu, does it helps with your issue? If yes, I'll bind it into MixerX's arguments, so, you will be able to use it.

Wohlstand avatar Aug 18 '22 02:08 Wohlstand

Still has bursting result...

Yave-Yu avatar Aug 20 '22 00:08 Yave-Yu

Then, I'll really try another thing...

Wohlstand avatar Aug 20 '22 01:08 Wohlstand

I should have tried this track to begin with. And watched that recent video.

ReplayGain results for the first track, with the (digital) "analog" simulation filter, and the 1.4x gain, which I disable on GME and apply in floating point afterward:

Track Gain: -13.74 dB Track Peak: 1.376801

You're definitely hearing clipping. I need to fix this in Cog, too, because that doesn't do the 1.4x volume scale in floating point, either.

kode54 avatar Aug 20 '22 07:08 kode54