#29944 - bertsnks - Sat Nov 27, 2004 1:23 am
Whenever I stop a looping sound abruply and immediatly play a different sound, my mixer generates a "click" noise, does anyone know why this happens and how it can be fixed on GBA without much CPU usage?
#29993 - DekuTree64 - Sat Nov 27, 2004 10:04 am
Yeah, usually that's caused by the sound being too far from 0 at the time you cut it. The 'correct' way to deal with it is to fade the volume out over a few samples so there's no abrupt change (fading over about 16 or 32 samples is usually enough).
That can be a bit tricky since you generally need the channel to play something else immediately after the fadeout, so you'd have to make sure the fading happened in the samples BEFORE the song update or the channel's vars will be overwritten, but until the song update happens, you don't know which channels to fade. Plenty of ways to deal with it, but no clear good ones.
One trick that really helps is to only fade the last sample value that was played, rather than updating the channel during it. The volume is dropping so fast anyway that you can't tell the difference, and then you can just record the output level (sample*volume) of the channel during the song update when you're cutting it, and then fade that value over the few samples AFTER the song update.
Be sure to clip it though, since that channel will be outputting new data as well as the fading level, so it could potentially overflow things.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku