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