Sound "pops" in SDL_Mixer -- any ideas for a fix?

I’m using SDL_Mixer (latest version) and sometimes get a static “pop” at the end of a sound, right when it stops playing. It is random whether a sound will contain this “pop” or not, however, if it has one, it’ll stay for the duration of the game. If you quit and restart the game, a different set of sounds will have pops and others not. Sometimes the pop is soft, other times quite loud and noticeable. If it’s soft, it’ll stay the same volume until you quit and restart.

I tried adding extra whitespace to the end of some of my sounds, to see if this would help. It didn’t. Only thing it did was delay the pop until the whitespace was done.

I tried also using .ogg vs. .wav, in case it was a format-loading issue. No change.

The sounds are recorded at 44,100 sample rate.

I wouldn’t know where to begin to try to fix this, but am happy to try if anyone more knowledgeable about sound mixers could give me a tip or two about what to try tweaking in SDL_Mixer.

It’d seem to be an issue with loading, given that the pops, or lack thereof, stay consistent for all playbacks of the same effect, until you quit and restart. But if it’s a loading issue, would it be random whether it pops or not?

Popping sounds may be a symptom of your chunksize being too small when you call
int Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize).
How big is your chunksize? You may want to increase it to, say 4096 or even more.

Also, what OS are you on? On Linux, a badly configured sound server can cause latency
and popping sounds.

This sounds more like a loading issue to me - perhaps the resampling code is reading past the end of the sound and getting garbage data at the end for one sampleframe (or reading before the beginning)?

Perhaps the sound is being padded at load with extra sampleframes that are uninitialized?

If it was consistent I would be saying the sound may have a misaligned baseline value or miss a proper lead-in/lead-out (if the start and end are not at 0 amplitude, you can get pops).On 07/28/2011 10:50 PM, Beoran wrote:

Popping sounds may be a symptom of your chunksize being too small when you call
int Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize).
How big is your chunksize? You may want to increase it to, say 4096 or even more.

Also, what OS are you on? On Linux, a badly configured sound server can cause latency
and popping sounds.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier