set up the volume

hi,

i don’t know how to set the volume of a sounds.

in the documentation i don’t see this

http://docs.coronalabs.com/api/library/audio/play.html

is it possible ?

Hi

It’s very simple, do this

local Vol = 0.5
    audio.setVolume( Vol )

This sets the volume of all your sounds, it’s the master volume control.

Individual sounds…

local laserSound = audio.loadSound( “laserBlast.wav” )

laserSound = audio.play( laserSound )
                audio.setVolume( 0.8, { channel=laserSound } )

hi,

thanks for your response. i come back to you later with a snippet because my problem is more complex than that  :slight_smile:

Sure, happy to help.

hi,

so to simplify when i have two function in same time i don’t hear the difference with the volume.

how can i do to have a louder sounds than the other ?

function mjump( ... ) jump = audio.loadSound( "piece.wav" ) audio.setVolume( 0.01, { channel=jump } ) laserChannel = audio.play( jump ) end function mboum( ... ) bum = audio.loadSound( "boum.mp3" ) audio.setVolume( 0.99, { channel=bum } ) laserChannel = audio.play( bum ) end mjump() mboum()

Hi

Personally I would load the sounds outside of the functions at the top of the main chunk.

Secondly you are using the same variable to play both sounds.

load the sounds at the top of your code like this:

local jumpSound = audio.loadSound( “piece.wav” )

audio.setVolume( 0.1, { channel=jumpSound } )

local bumSound = audio.loadSound( “boum.mp3” )

audio.setVolume( 0.6, { channel=bumSound } )

function mjump( … )

jumpSound = audio.play( jumpSound )

end

function mboum( … )

bumSound = audio.play( bumSound )

end

Hope this helps.

hi,

thanks for the correction.

I have tried with your code but I have already the same volume with the two sounds…

With this link below (wetransfer) I put my project file with the sounds (464ko)

Could you test at home ?

http://we.tl/TimkbWMNKB

Hi

It’s very simple, do this

local Vol = 0.5
    audio.setVolume( Vol )

This sets the volume of all your sounds, it’s the master volume control.

Individual sounds…

local laserSound = audio.loadSound( “laserBlast.wav” )

laserSound = audio.play( laserSound )
                audio.setVolume( 0.8, { channel=laserSound } )

hi,

thanks for your response. i come back to you later with a snippet because my problem is more complex than that  :slight_smile:

Sure, happy to help.

hi,

so to simplify when i have two function in same time i don’t hear the difference with the volume.

how can i do to have a louder sounds than the other ?

function mjump( ... ) jump = audio.loadSound( "piece.wav" ) audio.setVolume( 0.01, { channel=jump } ) laserChannel = audio.play( jump ) end function mboum( ... ) bum = audio.loadSound( "boum.mp3" ) audio.setVolume( 0.99, { channel=bum } ) laserChannel = audio.play( bum ) end mjump() mboum()

Hi

Personally I would load the sounds outside of the functions at the top of the main chunk.

Secondly you are using the same variable to play both sounds.

load the sounds at the top of your code like this:

local jumpSound = audio.loadSound( “piece.wav” )

audio.setVolume( 0.1, { channel=jumpSound } )

local bumSound = audio.loadSound( “boum.mp3” )

audio.setVolume( 0.6, { channel=bumSound } )

function mjump( … )

jumpSound = audio.play( jumpSound )

end

function mboum( … )

bumSound = audio.play( bumSound )

end

Hope this helps.

hi,

thanks for the correction.

I have tried with your code but I have already the same volume with the two sounds…

With this link below (wetransfer) I put my project file with the sounds (464ko)

Could you test at home ?

http://we.tl/TimkbWMNKB