With this function you can set how many audio channels are available for playing audio in GameMaker.
This basically means the number of sounds (or sound instances or voices) that can be played simultaneously. Or, put differently, the number of calls to any of the audio_play_sound_ functions that you can make before sounds may be lost.
If the number exceeds this value, those sounds with a lower priority are stopped to free up a channel for the sounds with a higher priority.
TIP You can use this function to optimise your game for devices as the lower the number of channels for audio the better the performance, but bear in mind that this may also cause noticeable cutoff of certain sounds if many are played at once.
WARNING This function is a configuration function of the audio engine and stops all playing sounds when called (i.e. audio_stop_all). Ideally it should not be called when sounds are already playing, unless you are e.g. using this as an adjustable setting in your game.
audio_channel_num(num);
Argument | Type | Description |
---|---|---|
num | Real | Number of available audio channels (default is 128) |
N/A
switch (os_browser)
{
case browser_not_a_browser:
switch (os_type)
{
case os_windows:
case os_macosx:
audio_channel_num(200);
break;
default:
audio_channel_num(64);
break;
}
break;
default:
audio_channel_num(16);
break;
}
The above code checks the platform that the game is running on and changes the number of available sound channels to increase performance.