Next, we will see how to control some of the main properties of sound, starting with its volume. This is done with a simple call to the setVolume()
method, which takes a value ranging from 0
(silence) to 1
(maximum volume):
channel->setVolume(1.0f);
Similar to the way we paused the sound earlier, we can also silence it temporarily by using the setMute()
method. Once we unmute the sound, it continues playing at its previous volume:
channel->setMute(true);
Both the methods preciously mentioned modify all channels of the sound simultaneously. On a sound with multiple channels, we can modify the volume of each channel separately, using the setInputChannelMix()
method. This works for any amount of channels, by taking an array of volume levels as the first parameter, and the number of channels as the second. The following is an example for a stereo sound that mutes the left channel:
float levels[2] = {0.0f, 1.0f}; channel->setInputChannelMix(levels, 2);