libgme / game-music-emu

Blargg's video game music emulation library, which allows audio applications to easily add playback support for the music of many classic video game consoles.
GNU Lesser General Public License v2.1
68 stars 12 forks source link

Resampler reduces quality a bit #36

Closed Wohlstand closed 4 years ago

Wohlstand commented 5 years ago

Original report by Wohlstand (Bitbucket: Wohlstand, GitHub: Wohlstand).


While listening VGM songs with YM2612 chip, I hearing that sound is smoothed which can be better recognized while listening FM-generated drums.

Here is my shitty attempt which fixes quality of VGM, but damages quality of SPC even more:

https://bitbucket.org/Wohlstand/game-music-emu/commits/branch/better-resampler

I have attached next files:

Wohlstand commented 5 years ago

Original comment by Wohlstand (Bitbucket: Wohlstand, GitHub: Wohlstand).


How it sounds now (it's smoother and it's hearing some of sound damage)

Wohlstand commented 5 years ago

Original comment by Wohlstand (Bitbucket: Wohlstand, GitHub: Wohlstand).


Sample VGM file (to play it correctly this PR is required)

Wohlstand commented 5 years ago

Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).


Fir_Resampler has templated parameters to adjust quality of resampling, it would be possible to use different settings for VGM vs. SPC. VGM seems to use Dual_Resampler (which uses Fir_Resampler<12> behind the scenes), do you think it makes sense to try increasing the resampler width for VGM to fix audio quality instead?)

Wohlstand commented 5 years ago

Original comment by Wohlstand (Bitbucket: Wohlstand, GitHub: Wohlstand).


I also have tried to increase this number, however, nothing is changing. Anyway, FM chips doesn’t needs resampling and their output should be passed non-distorted. This resampler does distorsion of sound by unnecessary smoothing.

Wohlstand commented 5 years ago

Original comment by Wohlstand (Bitbucket: Wohlstand, GitHub: Wohlstand).


Okay, for the case of FM, I made next: https://bitbucket.org/Wohlstand/game-music-emu/commits/03d70998bbbb065231c8c70f58c62ccd24e6896a

which is a very quick solution which avoids resampling when it’s not needed: simply pass data as-is, but don’t distort it by unnecessary smoothing.

Wohlstand commented 4 years ago

Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).


resampler: Don't resample when sample rates are matched.

The FIR resampler is always in use on some emulators (VGM in particular but also SPC). The resampler produces high quality output when we have to resample, but we don't always have to resample and in that situation it's better to avoid adding noise.

This is a rework of a patch Wohlstand submitted [1] since it felt cleaner to me and doesn't rely on floating point arithmetic to be exact.

This fixes #34. I can't even tell apart the "bad" and "good" quality samples though so if I've still got it wrong, please reopen.

[1] https://bitbucket.org/Wohlstand/game-music-emu/commits/03d70998bbbb065231c8c70f58c62ccd24e6896a

Wohlstand commented 4 years ago

Original comment by Wohlstand (Bitbucket: Wohlstand, GitHub: Wohlstand).


One commit you forgot to take: https://bitbucket.org/mpyne/game-music-emu/pull-requests/18/mame-ym2612-enable-internal-re-sampler-to

I have re-enabled MAME’s internal resampler which improves the sounding accuracy on it. Nuked is already accurate, MAME needed a little trick I made long time ago, but I have forgot to enable it here.