LIJI32 / SameBoy

Game Boy and Game Boy Color emulator written in C
https://sameboy.github.io/
Other
1.67k stars 210 forks source link

Attenuated treble on DMG #348

Open jkotlinski opened 3 years ago

jkotlinski commented 3 years ago

When comparing an ad hoc white noise signal played back through wave channel, I found SameBoy 0.13.6 remarkably close to a real DMG A/B/C. While the digital signal generation seems impeccable, I found a difference in high-end of the spectrum, giving real hardware an edge due to a sharper, crisper and ultimately more satisfying sound. The difference is confirmed by spectral analysis, which shows that Sameboy audio above 8 kHz is attenuated by a few dB.

Test files: noise.zip

Spectrogram

The image shows two superimposed signals. Red = DMG, purple = SameBoy 0.13.6. It can be seen that DMG signal is 1-2 dB louder above 8 kHz.

overlay
jkotlinski commented 3 years ago

After inspecting the code, it feels plausible that this error is introduced when downsampling APU output to 48 kHz.

jkotlinski commented 3 years ago

As a sanity check, I made the same comparison with Gambatte (configured to use Highest Quality FIR downsampler). Here, there is no serious roll-off until 17 kHz. I think the difference is audible and Gambatte certainly sounds closer to the real thing.

gambatteoverlay

gambatte.wav.zip

LIJI32 commented 3 years ago

Could also be different high-pass-filter constants as well as the lack of a low pass filter in SameBoy.

jkotlinski commented 3 years ago

Maybe Blip Buffer could be incorporated for the resampling?

IMO this would be the last hurdle for 100% audio emulation.

jkotlinski commented 3 years ago

I investigated further. In the samples attached in this message, it looks like most of the difference is from wave refresh audio spikes being more pronounced on real DMG. So in this particular case, Sameboy is "too good" :) which is maybe not a disaster.

808.zip

jkotlinski commented 3 years ago

As a summary, my analysis now is that the DC blocker emulation is a bit off. Sometimes it sounds better, sometimes it sounds worse.

You can choose for yourself, if it is something worth fixing :-)

lpla commented 3 years ago

Definitely, the 808.zip comparison is clearly audible. How other emulators behave with this test?

jkotlinski commented 3 years ago

Gambatte is very close to Sameboy. BGB is different, also not so much like real hardware.

On Tue, 20 Apr 2021 at 09:17, Leopoldo Pla @.***> wrote:

Definitely, the 808.zip comparison is clearly audible. How other emulators behave with this test?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LIJI32/SameBoy/issues/348#issuecomment-823038673, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY34OYGBLI33PYTHLTWLZLTJUTA7ANCNFSM4YG5WMMQ .