Mute all sounds except for one specific sound.

So i got background music set to channel 1

And (lets say 50) other sounds set to no channel.

I can’t set the other sounds to one channel because no sounds will play if something is playing already.

I can do: audio.setVolume(0) to mute everything but it will mute the background music.

What can I do to mute everything except the background music?

There are at least two ways:

  1. Keep track of handles when playing sounds.

  2. Keep track of channel used for each sound.

Using that info, mute all but the one you want not muted.  All this is in the API docs.

If I put all 50 sounds into 1 channel, is there anyway to ignore the thing where it won’t let any new sound play if something is already playing?

I usually just cycle through the channels 2-16 when each new sound is being triggered. Then it’s much less likely a sound will already be playing on that channel, and if so I can just stop it first.

I actually did this and it worked out better:

audio.setVolume(0,{channel=0}) audio.setVolume(1,{channel=1})

This line:

audio.setVolume(0,{channel=0})

would mute all channels and sounds(that are not set in channels) to 0.

Then this line:

audio.setVolume(1,{channel=1})

would set the volume of channel 1 to 100%.

Setting the volume of “channel 0” is not the same as setting the master volume.

There are at least two ways:

  1. Keep track of handles when playing sounds.

  2. Keep track of channel used for each sound.

Using that info, mute all but the one you want not muted.  All this is in the API docs.

If I put all 50 sounds into 1 channel, is there anyway to ignore the thing where it won’t let any new sound play if something is already playing?

I usually just cycle through the channels 2-16 when each new sound is being triggered. Then it’s much less likely a sound will already be playing on that channel, and if so I can just stop it first.

I actually did this and it worked out better:

audio.setVolume(0,{channel=0}) audio.setVolume(1,{channel=1})

This line:

audio.setVolume(0,{channel=0})

would mute all channels and sounds(that are not set in channels) to 0.

Then this line:

audio.setVolume(1,{channel=1})

would set the volume of channel 1 to 100%.

Setting the volume of “channel 0” is not the same as setting the master volume.