Log in

View Full Version : SDL_mixer delays before playing


compumatrix
06-06-2004, 12:58 PM
I decided to start implimenting sound in my game using SDL_mixer. Everything seems to be going fine except that when using Mix_PlayChannel the sound doesn't play immediatly. I was using a WAV file that had some dead air at the beginning so I chopped that off in audacity thinking that I had found the problem, but the problem continues. Maybe I will try a different sound clip incase there is something weird going on with the clip. I found a couple of results on google about this problem, but no real solutions.

Has anyone had similar problems, and how did you fix it?

Thanks,
Jon

ggambett
06-06-2004, 02:04 PM
Use a smaller buffer size in Mix_OpenAudio. The buffer is a FIFO, so the longer the buffer, the longer the delay. For example, at 22050 16 bit stereo samples you have 22050x2x2 = 88K / second. A 8K FIFO buffer will introduce a 1/10 second delay.

However, if the buffer is too small, you may have problems with high latency sound drivers - in particular the SB Live did stuttering.

I'm using 2048 and it seems to work in all cases.

compumatrix
06-06-2004, 08:18 PM
Thanks for the reply, that fixed it. Mine was set to 4096 as it was in the tutorial I read. I was going to play around with that value at one point, but then didn't and I wasn't sure what a good value to use was. I'm glad I know that I am using the buffer size that seems to work for you.

Also, has anyone had problems with joysticks giving garbage data on the first input event or so (at least with axies)? Because, I seem to be experiencing a problem with that as well...

Thanks Again,
Jon Kuhn