Advertisement Jump to content
Sign in to follow this  

SDL_Mixer 'pop' noise

This topic is 4919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to use SDL_Mixer to make some audio clips from scratch. I've been trying to make a silent clip. When I play the clip, I get a slight 'pop' at the beginning and end. What could be causing this? Here's my code (with unimportant bits taken out):
Mix_Chunk * sample;
const int RATE = 44100;

// Init audio
Mix_OpenAudio(RATE, AUDIO_S8, 1, 4096);

// Create a sample 1 second long
sample = new Mix_Chunk;
sample->alen = RATE; 
sample->abuf = (Uint8*)malloc(sample->alen); 
sample->volume = 128;

// This is called when the mouse is clicked, inside a main loop.
// This only happens once upon clicking and does not repeat every loop. I had this problem originally but I fixed it

// Close audio

Thanks a lot, Kris. PS: This doesn't happen if I load a sample from a .wav file, silent or otherwise [Edited by - Kris_A on August 2, 2005 5:22:25 PM]

Share this post

Link to post
Share on other sites
I could be speaking out of my arse here (not knowing how SDL_Mixer works), but I'll try and offer my solution [smile].
Currently, it doesn't look like you're setting the sample level to anything in particular, right? A silent clip would be one that would be full of the centre-point of the sound - so for an 8-bit sound (which is what you seem to be using) you would set the levels to 127. 0 is the lowest trough and 255 is the highest peak, so if you set the levels to 0 the sound will dip down (and pop) from the centre-point when it starts and finishes.
I've only done this sort of thing loading the wave sounds out of a DOOM WAD file and playing them directly through SDL (no SDL Mixer) and to elminiate the pops I treated my "silence" level as 127 (when writing to the buffer) and it all seemed to work fine.

When you load a WAV file they will be balanced out so that they start and end at 127, hence no popping.

Share this post

Link to post
Share on other sites
ahh, of course, I just looked at the output in CoolEdit, and the 'base level' seems to be 127/128. Works perfectly now, thanks!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!