SDL_mixer Issue - no one talks about ?!

Hi, I have been coding my Engine and I have one thing left before I start coding first few games on it - Audio class with SDL_mixer chunk playback.

I have spent 3-4 days researching this issue and found that no one is talking about it.

The Issue: using Mix_PlayChannel(); to play sound rapidly to simulate things, like Shooting a gun, Car Engine Roaring, Laser Shooting… Something that has the same sound file and is played with (for example) 100ms delay to get this rapid, machine gun fire like sound when Button is DOWN.

I have used SDL_GetTicks() and SDL_GetPerformanceCounter() to measure (for example) 100ms and play the sound. But the problem is that playback is not consistent, even few ‘ms’ of time difference can be heard when sounds are played rapidly.

I have created simple demo to demonstrate this here: Source File + OGG file: http://goo.gl/PwHFNK
Sound file: http://goo.gl/OITlTR

Funny thing is, most of tutorials and even Books (Focus on SDL, SDL Game Programming) show you how to create SDL_mixer based sound class but skip the part where you have to play sounds in rapid progression like a shooting sound.

Anyone here had this issue and knows how to go about it?

Regards.
Juris.------------------------
Engine programmer for ANN-Tech. Interactive
www.ann-tech.com

It looks like nine times a second you play a ten second long or so sound
file. Since I don’t know your particular outcome I think maybe it runs out
of buffer space or maybe complains that you are not addressing the call
correctly? If you check to see if it is playing before you play does it
work correctly?

The coders friend necronology / Alan / The AlanOn Thu, Dec 5, 2013 at 1:24 PM, JurisL85 wrote:

Hi, I have been coding my Engine and I have one thing left before I
start coding first few games on it - Audio class with SDL_mixer chunk
playback.

I have spent 3-4 days researching this issue and found that no one is
talking about it.

The Issue: using Mix_PlayChannel(); to play sound rapidly to simulate
things, like Shooting a gun, Car Engine Roaring, Laser Shooting…
Something that has the same sound file and is played with (for example)
100ms delay to get this rapid, machine gun fire like sound when Button is
DOWN.

I have used SDL_GetTicks() and SDL_GetPerformanceCounter() to measure (for
example) 100ms and play the sound. But the problem is that playback is not
consistent, even few ‘ms’ of time difference can be heard when sounds are
played rapidly.

I have created simple demo to demonstrate this here: Source File + OGG
file: http://goo.gl/PwHFNK
Sound file: http://goo.gl/OITlTR

Funny thing is, most of tutorials and even Books (Focus on SDL, SDL Game
Programming) show you how to create SDL_mixer based sound class but skip
the part where you have to play sounds in rapid progression like a shooting
sound.

Anyone here had this issue and knows how to go about it?

Regards.
Juris.


Engine programmer for ANN-Tech. Interactive
www.ann-tech.com


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

For some reason it has been transfered to this thread:
https://forums.libsdl.org/viewtopic.php?t=9805------------------------
Engine programmer for ANN-Tech. Interactive
www.ann-tech.com

[…]

Not sure what happened, but there were two posts to the mailing list,
and there have been replies to both of them. I suspect they’re handled
as independent threads by both interfaces.On Mon, Dec 9, 2013 at 10:13 AM, JurisL85 wrote:

For some reason it has been transfered to this thread:
https://forums.libsdl.org/viewtopic.php?t=9805

//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’