The audio system also has the ability to alter the minimum and maximum states of audio volume as well as audio fades when needed in your application.
The volume of audio can be set with values ranging from 0 to 1.0. This setting can be adjusted at any time before or during the extended sound playback.
Syntax:
audio.setVolume( volume [, {[channel=c]} ] )
Parameters:
volume
- The new volume level you want to apply. Valid numbers range from 0.0 to 1.0, where 1.0 is the maximum volume value. Default volume is based on your device ringer volume and will vary.channel
- The channel number you want to set the volume on. Channel number 1 to the maximum number of channels. Specify 0 to apply the volume to all the channels. Omitting this parameter entirely sets the master volume, which is different than the channel volume.
Example:
audio.setVolume(0.75) -- set master volume
audio.setVolume(0.5, {channel=2}) -- set volume on channel 2