Audio.fadeOut fade every channel

Hi,

In my new game, there is a day/night transition that occur when the player reach the needed distance.
I use 2 different music, one for the day and one for the night and I change between them like this:

[lua]if(player.distance > distanceJour) then
distanceJour = distanceJour+50
if(currentDay == “Jour”)then
currentDay = “Soir”
transition.to(filtreSoir, { time=500, alpha = 0.4} )
elseif(currentDay == “Soir”)then
audio.fadeOut( backgroundMusic, { channel=3, time=2000 } )
audio.setVolume( 1, { channel=4 } )
audio.play( backgroundMusicNight, { channel=4, loops=-1, fadein=1000 } )
currentDay = “Nuit”
transition.to(filtreNuit, { time=500, alpha = 0.6} )
transition.to(filtreSoir, { time=500, alpha = 0} )
elseif(currentDay == “Nuit”)then
audio.fadeOut( backgroundMusicNight,{ channel=4, time=2000} )
audio.setVolume( 1, { channel=3 } )
audio.play( backgroundMusic, { channel=3, loops=-1, fadein=1000 } )
currentDay = “Matin”
transition.to(filtreSoir, { time=500, alpha = 0.4} )
transition.to(filtreNuit, { time=500, alpha = 0} )
elseif(currentDay == “Matin”)then
currentDay = “Jour”
transition.to(filtreNuit, { time=500, alpha = 0} )
transition.to(filtreSoir, { time=500, alpha = 0} )
end
end[/lua]

And that work really great! The song cycle between each other. The problem is that when I use the fadeOut, even if I specify the channel, the sound in my games all fade out with the music.

For short story, in the game, we control a Rocket. When we press the screen, the Rocket goes up and when we release, it fall. So for the time we press the screen, I want to have a fire sound that loop indefinitly.

I create the sound at the beginning of the game, like this :
fire = audio.play( fire,{loop=-1, channel= 2} )

And I cycle the fire like this:
[lua]if(fall == true) then
tnt:newTransition( player, { rotation = 45, time=400 } )
player:prepare(“idle”)
player:play()
fire = audio.pause( {channel = 2} )
fire = audio.rewind( { channel = 2 } )
end
if(fall == false)then
tnt:newTransition( player, { rotation = -45, time=400 } )
player:prepare(“engine”)
player:play()
fire = audio.resume( fire,{channel= 2} )
end[/lua]

Again, everything work just fine…but when I reach the correct distance, the fadeOut on the background music(On channel 3) actually fadeOut the fire sound too(On channel 2)! Actually, even if I remove the first fadeOut, the second fade out, for the second music(On Channel 4) Still fadeOut the fire sound…

So, does anyone know what i’m doing wrong? Why the fadeOut on channel 3 affect another channel?

Thank you! [import]uid: 181680 topic_id: 35536 reply_id: 335536[/import]

Well I’m not sure if this will fix it or not, but when you call fadeOut you are doing this:

audio.fadeOut( backgroundMusic, { channel=3, time=2000 } )

However when I call fadeOut I do this:

audio.fadeOut({ channel=3, time=2000 } )

The docs seems to say that you only need to use the channel and time in the function parameters.

I know that if you provide 0 as the channel, it fades out all sounds. My guess would be that since you are giving it a sound object as a parameter (which is not valid) it just takes that as nil and fades all sounds out.

Hopefully all you need to do is change it to:

audio.fadeOut({ channel=3, time=2000 } ) --line 7  
  
audio.fadeOut({ channel=4, time=2000 } ) --line 14  

Edit: I think the same is true for your audio.resume() call. If you already know the channel number, you can just use:

audio.resume( { channel = 2} ) [import]uid: 84115 topic_id: 35536 reply_id: 141241[/import]

Wow…actually…that solved everything!! It seem you are right! Good to know about that!

A big thank you for you, and have a nice day! [import]uid: 181680 topic_id: 35536 reply_id: 141244[/import]

Well I’m not sure if this will fix it or not, but when you call fadeOut you are doing this:

audio.fadeOut( backgroundMusic, { channel=3, time=2000 } )

However when I call fadeOut I do this:

audio.fadeOut({ channel=3, time=2000 } )

The docs seems to say that you only need to use the channel and time in the function parameters.

I know that if you provide 0 as the channel, it fades out all sounds. My guess would be that since you are giving it a sound object as a parameter (which is not valid) it just takes that as nil and fades all sounds out.

Hopefully all you need to do is change it to:

audio.fadeOut({ channel=3, time=2000 } ) --line 7  
  
audio.fadeOut({ channel=4, time=2000 } ) --line 14  

Edit: I think the same is true for your audio.resume() call. If you already know the channel number, you can just use:

audio.resume( { channel = 2} ) [import]uid: 84115 topic_id: 35536 reply_id: 141241[/import]

Wow…actually…that solved everything!! It seem you are right! Good to know about that!

A big thank you for you, and have a nice day! [import]uid: 181680 topic_id: 35536 reply_id: 141244[/import]