SDL sound plop

Started by
4 comments, last by Koshmaar 18 years, 7 months ago
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]
Advertisement
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?
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.
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 :-)
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.
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.

This topic is closed to new replies.

Advertisement