audio.gain read/write property
Get or set the master gain, the global loudness of sounds in decibels. This property provides global amplification of sounds.
This property default value is set to 0.0
. Positive values will amplify sounds, while negative values will quieten sounds.
Example
local audio = require "audio"
local console = require "console"
print("Playing some music")
print("Press UP and DOWN arrow keys to change gain")
print("Press SPACE to exit")
-- Play some music
audio.play("music.mp3")
while true do
local c, special = console.readchar()
if special == true then
if c == "H" then -- UP key have been pressed
audio.gain = audio.gain + 1
print("Audio gain set to "..audio.gain)
elseif c == "J" then -- DOWN key have been pressed
audio.gain = audio.gain - 1
print("Audio gain set to "..audio.gain)
end
elseif c == " " then -- SPACE key have been pressed
print("Stop playing...")
break
end
end