LIJI32 / SameBoy

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

PCM playback buzz audible in SameBoy but not on GBA SP #555

Closed SonoSooS closed 9 months ago

SonoSooS commented 1 year ago

I've made a really really crude PCM player, but I've noticed that when reloading Wave RAM, it causes an audible whine/buzz (at the frequency of the reload timer) in SameBoy when disabling and re-enabling CH3, but on my GBA SP it only causes white noise (except at the end of the song, where it causes a whine on real hardware as well).

I have SameBoy set to GBA in the emulation settings, and high pass filter to accurate. Interference noise can be at 0% or 100%, I still hear the buzz. I'm on Windows, so I have the SDL version.

The way I do PCM playback is that I disable CH3 in NR51 before disabling NR30, reload Wave RAM, re-enable NR30, trigger via NR34, then re-enable CH3 in NR51. This is all happening on a timer. After reloading Wave RAM, I HALT the CPU, so the timing is as predictable as possible. I use self-modifying code in RAM with no conditionals, so the timing is as predictable as possible.

Test ROM (needs a 4MB MBC5 cartridge): GBTP.zip