audio.findFreeChannel()

Type Function
Library audio.*
Return value Number
Revision 2017.3060
Keywords audio, channels, free channels
See also audio.play()
audio.reserveChannels()

Overview

Looks for an available audio channel for playback. You can provide a start channel number as parameter and begin searching from that channel, increasing upward to the highest channel. The search does not include reserved channels.

This function returns the channel number of an available channel or 0 if none could be found.

Syntax

audio.findFreeChannel( [ startChannel ] )
startChannel (optional)

Number. The channel number you want to start looking at. Search will increase upwards from this channel. 0 or no parameter begins searching at the lowest possible value.

Example

local availableChannel = audio.findFreeChannel()
audio.play( laserSound, { channel=availableChannel } )