Music and SFX volume management

Hi, all.
How can I manage the volume of my game music separated from the volume of my game sfx?

Thanks. [import]uid: 162818 topic_id: 36885 reply_id: 336885[/import]

Hi there,

You can reserve a specific audio channel for your music using audio.reserveChannels (http://docs.coronalabs.com/api/library/audio/reserveChannels.html), and set its volume separately from the volume of the other channels, which you can use for sound effects.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36885 reply_id: 145135[/import]

Yeah! That’s what I need! Thank you, From-aukStudios-dude. :smiley: [import]uid: 162818 topic_id: 36885 reply_id: 145136[/import]

Hi there,

You can reserve a specific audio channel for your music using audio.reserveChannels (http://docs.coronalabs.com/api/library/audio/reserveChannels.html), and set its volume separately from the volume of the other channels, which you can use for sound effects.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36885 reply_id: 145135[/import]

Yeah! That’s what I need! Thank you, From-aukStudios-dude. :smiley: [import]uid: 162818 topic_id: 36885 reply_id: 145136[/import]

Hi there,

You can reserve a specific audio channel for your music using audio.reserveChannels (http://docs.coronalabs.com/api/library/audio/reserveChannels.html), and set its volume separately from the volume of the other channels, which you can use for sound effects.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36885 reply_id: 145135[/import]

Yeah! That’s what I need! Thank you, From-aukStudios-dude. :smiley: [import]uid: 162818 topic_id: 36885 reply_id: 145136[/import]

Hi again, aukStudios. I’m getting a problem. I can’t set specific sounds to the channels I’ve reserved.
What shall I do? [import]uid: 162818 topic_id: 36885 reply_id: 145492[/import]

Hi there,

When you call [lua]audio.play()[/lua], are you including the channel that you want the sound or music to play on? You could do it like this:

[blockcode]
local myMusic = audio.loadStream(“myMusicFile.mp3”)
local mySound = audio.loadSound(“mySoundFile.wav”)

audio.reserveChannels(2)

local myMusicChannel = 1
local mySoundChannel = 2

audio.setVolume( 0.15, { channel=myMusicChannel } ) – Soft music
audio.setVolume( 1, { channel=mySoundChannel } ) – Loud sound effects

audio.play( myMusic, { channel=myMusicChannel } )
audio.play( mySound, { channel=mySoundChannel } )
[/blockcode]

  • Andrew [import]uid: 109711 topic_id: 36885 reply_id: 145493[/import]

Ahhh! That’s it!
I was setting the sound to channel like this:
[lua] audio.loadSound(“blabs.ogg”, {channel = 1})[/lua]

Thanks you once more, dude! :smiley: [import]uid: 162818 topic_id: 36885 reply_id: 145495[/import]

Hi there,

You can reserve a specific audio channel for your music using audio.reserveChannels (http://docs.coronalabs.com/api/library/audio/reserveChannels.html), and set its volume separately from the volume of the other channels, which you can use for sound effects.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36885 reply_id: 145135[/import]

Yeah! That’s what I need! Thank you, From-aukStudios-dude. :smiley: [import]uid: 162818 topic_id: 36885 reply_id: 145136[/import]

Hi again, aukStudios. I’m getting a problem. I can’t set specific sounds to the channels I’ve reserved.
What shall I do? [import]uid: 162818 topic_id: 36885 reply_id: 145492[/import]

Hi there,

When you call [lua]audio.play()[/lua], are you including the channel that you want the sound or music to play on? You could do it like this:

[blockcode]
local myMusic = audio.loadStream(“myMusicFile.mp3”)
local mySound = audio.loadSound(“mySoundFile.wav”)

audio.reserveChannels(2)

local myMusicChannel = 1
local mySoundChannel = 2

audio.setVolume( 0.15, { channel=myMusicChannel } ) – Soft music
audio.setVolume( 1, { channel=mySoundChannel } ) – Loud sound effects

audio.play( myMusic, { channel=myMusicChannel } )
audio.play( mySound, { channel=mySoundChannel } )
[/blockcode]

  • Andrew [import]uid: 109711 topic_id: 36885 reply_id: 145493[/import]

Ahhh! That’s it!
I was setting the sound to channel like this:
[lua] audio.loadSound(“blabs.ogg”, {channel = 1})[/lua]

Thanks you once more, dude! :smiley: [import]uid: 162818 topic_id: 36885 reply_id: 145495[/import]