audio.getVolume()

Type Function
Library audio.*
Return value Number
Revision Release 2024.3703
Keywords audio, volume
See also audio.setVolume()

Overview

Gets the volume for a specific channel, or gets the master volume.

This function returns:

Gotchas

Note that the master volume is not necessarily the device's ringer volume. However, all volumes are scaled proportionally to the ringer volume.

Syntax

audio.getVolume( { channel=c } )
channel (optional)

Number. The channel number you want to get the volume on. Valid channels are 1 to the maximum number of channels (currently 32). Specifying 0 will return the average volume across all channels. Omitting this parameter entirely gets the master volume which is different than the channel volume. All channel volumes are scaled by the master volume.

Example

local masterVolume = audio.getVolume()  -- get the master volume
local channel1Volume = audio.getVolume( { channel=1 } ) -- get the volume on channel 1