audio.reserveChannels()

Description:

Allows you to reserve a certain number of channels so they won't be automatically assigned to play on. This function blocks off the lower number channels up to the number you specify so they won't be automatically assigned to be played on when you call various play functions.

For example, if there are 32 channels available, and you pass 2 into this function, channels 1 and 2 will be reserved so they won't be played on automatically when you specify you want to play a sound on any available channel. You can still play on channels 1 and 2 if you explicitly designate you want to play on their channel number.

Setting back to 0 will clear all the reserved channels so all will be available again for auto-assignment.

As an example, this feature can be useful if you always want your music to be on channel 1 and speech on channel 2 and you don't want sound effects to ever occupy those channels. This allows you to build in certain assumptions about your code, perhaps for example, having different volume levels for music, speech, and sound effects.

Specifying the number of reserve channels to the maximum number of channels will effectively disable auto-assignment.

Syntax:

audio.reserveChannels( channels )

Example:

audio.reserveChannels( 2 )

Parameters:

channels
integer: The number of channels you want to reserve. 0 will unreserve all channels.

Returns:

Returns the number of currently reserved channels.

Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Build 2011.222
  • Windows:
    Build 2011.222
  • iOS:
    Build 2011.222
  • Android:
    Build 2011.222

Replies

clockworked24.7
User offline. Last seen 3 years 2 weeks ago. Offline
Joined: 21 May 2011

It would be really great if we had one more audio.reserve function:

audio.reserveChannel( channel# )

so we could specify which channel we want to reserve. That would be very useful for sound management.

Thanks!