Scroll to navigation

Mix_AllocateChannels(3) SDL_mixer3 FUNCTIONS Mix_AllocateChannels(3)

NAME

Mix_AllocateChannels - Dynamically change the number of channels managed by the mixer.

SYNOPSIS

#include "SDL3_mixer/SDL_mixer.h"
int Mix_AllocateChannels(int numchans);

DESCRIPTION

SDL_mixer deals with "channels," which is not the same thing as the mono/stereo channels; they might be better described as "tracks," as each one corresponds to a separate source of audio data. Three different WAV files playing at the same time would be three separate SDL_mixer channels, for example.

An app needs as many channels as it has audio data it wants to play simultaneously, mixing them into a single stream to send to the audio device.

SDL_mixer allocates MIX_CHANNELS (currently 8) channels when you open an audio device, which may be more than an app needs, but if the app needs more or wants less, this function can change it.

If decreasing the number of channels, any upper channels currently playing are stopped. This will deregister all effects on those channels and call any callback specified by Mix_ChannelFinished () for each removed channel.

If numchans is less than zero, this will return the current number of channels without changing anything.

FUNCTION PARAMETERS

the new number of channels, or < 0 to query current channel count.

RETURN VALUE

Returns the new number of allocated channels.

AVAILABILITY

This function is available since SDL_mixer 3.0.0.

SDL_mixer 3.0.0 SDL_mixer