How others are handling sdl_mixer channels

Hi, I’m just getting into SDL_mixer, and learning the library. I’ve
never done anything with sound before, so forgive me for being naive. I
just want to get a high level idea of how others are handling mixer
channels, specifically how to test for a sound already playing.
In my program, I have several sound effects. During an event, a sound
plays, but I don’t want the same sound effect piling up. So I tried to
come up with a way to test to see if a sound is already playing. One way
I can do that in sdl_mixer is to test if a channel is already playing.
So I came up with a set of enums, one per sound, and I play the sound on
a specific channel corresponding to the enum. This probably isn’t very
efficient but it seems to work. Another way I could track sounds is to
couple my sound with the channel it is playing on, then use the
channel_finished callback to let me know when the channel is done. There
are probably other ways of testing if a sound is done playing, but I
wanted to get an idea of how this sort of thing was intended to work,
and how others are doing it.

Jim

This is the strategy I’d recommend. Dedicating channels to specific
sounds will quickly cause your channel count to go through the roof,
which is bad.
-:sigma.SBOn Dec 24, 2007 10:55 AM, James Barrett wrote:

Another way I could track sounds is to couple my sound with the channel
it is playing on, then use the channel_finished callback to let me know
when the channel is done.