Jump to content
  • Advertisement
Sign in to follow this  
Mybowlcut

SDL_mixer - Mix_PlayChannel()

This topic is 4075 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey. When I try and play more than one sound with Mix_PlayChannel(), my game exits (gracefully though - it doesn't crash). I'd like to know how many channels I can have playing at once and how I can limit this number to say... 1. Thankyou. :)

Share this post


Link to post
Share on other sites
Advertisement
Hm... I'm not sure if I've misunderstood channels or not. Channels seem to be defined as 1 being mono and 2 being stereo. I thought it meant how many chunks could be played simultaneously. :s If I change my audio_engine initialisation function to this:

const bool Audio_Engine::Initialise() {
return(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, MIX_CHANNELS, 4096) == 0);
}


then in main, the program returns here:

//Initialise the Audio
if(AE.Initialise() == false) {
return 1;
}



I don't want to limit myself with this audio_engine class by only using one channel, but I'm not sure if I even understand channels! Haha. All I want to know is how to limit how many chunks and music can be played simultaneously, and if it can be done.

Share this post


Link to post
Share on other sites
Quote:
Mix_AllocateChannels
...
The number of channels allocated. Never fails...but a high number of channels can segfault if you run out of memory. --We're talking REALLY high!--


In Mix_OpenAudio, the channel parameter doesn't deal with mixing channels. Generally the maximum depends on your system memory, but you shouldn't run out any time soon. The documentation example suggests 16.

Normally, -I-, don't bother with allocating channels, I just play a sound on the next free channel. Although if you'd like to limit it to only 1 channel, Mix_AllocateChannels(1) should do the trick.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!