Closed joeyparrish closed 1 month ago
I tested your sample and indeed the PCM playback is really bad by default, this is because of the Z80 interruption on DMA / IO accesses. The flags are set by default in SGDK for safety as it may lead to some potential bugs on some systems (at least it has been verified for DMA, for IO access I never experienced it myself). Just set HALT_Z80_ON_DMA and HALT_Z80_ON_IO to 0 in the inc/config.h file then rebuild the library. Build your project to link with the new built library and you will see that PCM playback quality is slightly improved... As the sample does nothing except playing the PCM, the DMA is not the problem here, just the IO accesses (SGDK is pooling controllers during vblank process) are enough to disturb the PCM playback. I can probably try to shorten the Z80 interruption time to improve that though.
Just set HALT_Z80_ON_DMA and HALT_Z80_ON_IO to 0 in the inc/config.h file then rebuild the library.
I tried that before, but didn't notice much improvement. I'll try again, though. It has been a while.
I can probably try to shorten the Z80 interruption time to improve that though.
Please let me know if this works! I would be very grateful.
I just push a change which improve quite a bit the PCM playback with Z80_HALT_ON_IO set to 1. Don't hesitate to test and report your feeling about it.
That's a huge improvement. I can't tell the difference now between Z80_HALT_ON_IO set to 0 and to 1.
I guess we can close the issue ? :)
Yes, let's do that. Thank you for your support!
I'm having trouble with PCM audio playback quality. I have carefully filtered my PCM audio to avoid aliasing during downsampling, and my downsampled 13kHZ 8-bit PCM stream sounds much better when played with
ffplay
than it does when played through SGDK.The noise I experience during playback varies by which driver I use and what type of content it is, but it's basically a low static. For pop music, it's usually less noticeable, but for cinematic content, it seems worse.
I have experimented with the XGM2 and SND_PCM drivers. Each is noisy in slightly different ways. SND_PCM tends to be a little "wobbly" in a way XGM2 isn't. Overall, I like XGM2 better. I haven't managed to make MDSDRV work yet. (It plays samples for about 1 second, then just stops.)
I've attached simple source, samples (PCM & WAV formats), and ROMs of playback in different drivers. I hope it's useful.
audio-only.zip
Thanks for your help!