Sign in to follow this  

SDL sound plop

This topic is 4489 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

I'm using SDL to play sound data that I loaded in a buffer. When I play something, after it played, the speaker sais "plop", which is annoying. What to do to prevent this plop, does the sound data have to end in a special way or so? The sound data is 8-bit, and the sound file ends in value 126, so I guess value 127 or 128 represents the 0 level. Should I use AUDIO_U8 or AUDIO_S8 then for audio format (with S8 it sounds weird :s)? EDIT2: problem NOT fixed after all, I still hear plop at the end even if I fill the sound buffer with zeros or 127's at the end :( [Edited by - Lode on August 31, 2005 5:20:09 PM]

Share this post


Link to post
Share on other sites
Hmmm, what do you mean? You hear this "plop" at the end of whole program, when it is stopped, or do you hear it each time your sound rewinds and/or ends?

If the first, then AFAIK it's normal - I have the same "problem" with FMOD. When program exits, I hear plop :-)

If it's the latter, then it *may* be a bug in... SDL, SDL_Mixer or any other library that you're using (you haven't written that). IMHO you should post some code.


The other thing that could be generating this problem, are sounds themselves - have you tried playing other sounds / other sound formats?

Share this post


Link to post
Share on other sites
The pop is hearable after every sound played by the program.

I have the sound data stored in 8-bit values, going from 0 to 255, where 127 is the zero level of the sound (if you know what I mean). I think the plop has something to do with that after the sound is played, it jumps from 127 to 0 in the SDL sound buffer, which makes the plop. But yeah, the audio file is stored that way, and if the zero level would have to be a byte with value zero, then it would be impossible to contain less than zero sound valuess, so how to overcome this?

The original sound file should be allright, it sounds fine with a media player.

BTW I store the sound data in a png image. Each red color value of pixels is an 8-bit sound data value. Don't ask why.

Share this post


Link to post
Share on other sites
Do you own "Game Programming Gems #2"? There's a chapter called (forgive my lame translation [embarrass] ): "Method which allows for immediate using voice in synthezathor based on samples" which states that:

There is a problem when you want to play in single channel two sounds, one after another. The problem is related to the fact of sharp transition (difference of amplitude) between sounds, what causes the plop and other annoying sounds.


So it looks that probably you were right in your last post.


As I said, there's a whole chapter about overcoming this problem, and obviously I won't rewrite it here :-) but I can tell you, that the author's proposed method is to combine linear interpolation of old sound to 0 with new sound begginning - unfortunately, exact implementation / description is too long to write here.

If you don't have the time / will to fix it in code, maybe you could use some sound editor (ie. Audacity) and run your sounds through filter, which will make the end of sound not so sharp, which may eliminate plop.

Good luck :-)

Share this post


Link to post
Share on other sites
I don't think all that is necessary here, as the wav file sounds great in a media player, which means it correctly ends in a audio value 0.

With SDL's loadwav function, the data is stored in a Uint8 buffer, and appearantly the audio null values become 127 in there. If I add 128 to all the values, then the null value becomes 0, but it sounds very weird, but without plop.

Share this post


Link to post
Share on other sites
Well, if the problem isn't related to sound files, but rather with code, then you'll have to show us your code, so that we can check it out for bugs and/or compile and run it by ourselves.

Share this post


Link to post
Share on other sites

This topic is 4489 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this