Audio Won't Play Until Volume Reset

Hi all,

 

I’m having an odd problem regarding audio playback and Storyboard. In a given scene, I have background music playing, the volume level of which is adjustable by the user. This works fine. When you leave the scene to go to a different one, I call audio.stop, audio.dispose, and nil out the audio variables:

 

function scene:exitScene (e)     audio.stop()     audio.dispose(roomMusic\_A)     audio.dispose(roomMusic\_B)     roomMusic\_A = nil     roomMusic\_B = nil end

 

When returning to the first scene, the music seems to not be playing. However, if you adjust the volume in the in-game Settings menu, the music can then be heard, and it has indeed been playing back.

 

Essentially the Settings menu is doing this:

 

audio.setVolume(musicVolume, {channel=musicChannel})

 

Why isn’t it audible until I set the volume again?

 

As a workaround, I wrote a small function that refreshes the volumes on all channels every time you enter a scene, but I’d like to understand what’s really going on.

 

Thanks!

 

  • David

Interesting. My music stops working after a few scenes, thought it was a failure to function, but perhaps it has been playing all along, since the sound effects don’t seem to experience the same issue. I’ll give this a shot, but I’d like to know why it’s happening, too.  I guess it wouldn’t hurt to pop this command every now and then, especially if I have a timer loop running.

I’ve got this problem too and still not know how to handle this problem.

Can anybody explain what was happening?

@davidcondolora,

Are you using any kind of volume control on your music channel other than the Settings menu controller? Do you use a channel fade somewhere, i.e. when your scenes are ending? Have you dedicated and reserved a single channel for your music to play on, to ensure that it never gets auto-assigned by another audio track?

 

@BeyondtheTech, zulfahmi.andri,

In addition to the questions I pose above, note that there’s a “master” volume level and a per-channel volume level, independent of each other. Maybe you already know this, but I just wanted to mention it again, since it’s a fairly common oversight.

 

Brent

@Brent Sorrentino: Thanks for the reply! The music is playing on a single dedicated channel, but I am indeed using a channel fade. Everytime I leave a scene, I’m fading out all audio:

 

audio.fadeOut({channel=0, time=fadeLength})

 

I just looked at the API reference, and it says that the value is persistent, and it’s my responsibility to reset my audio levels. So it looks like my function to reset the volumes every time I enter a new scene is actually the right way to do it, if I want to fade everything out when I leave a scene. Now I understand what’s going on.

 

Thanks a lot for the help!

 

  • David

Well, I have to search through all my project codes because many of them are generated code by third party tool.

Thanks Brent for the help.

Interesting. My music stops working after a few scenes, thought it was a failure to function, but perhaps it has been playing all along, since the sound effects don’t seem to experience the same issue. I’ll give this a shot, but I’d like to know why it’s happening, too.  I guess it wouldn’t hurt to pop this command every now and then, especially if I have a timer loop running.

I’ve got this problem too and still not know how to handle this problem.

Can anybody explain what was happening?

@davidcondolora,

Are you using any kind of volume control on your music channel other than the Settings menu controller? Do you use a channel fade somewhere, i.e. when your scenes are ending? Have you dedicated and reserved a single channel for your music to play on, to ensure that it never gets auto-assigned by another audio track?

 

@BeyondtheTech, zulfahmi.andri,

In addition to the questions I pose above, note that there’s a “master” volume level and a per-channel volume level, independent of each other. Maybe you already know this, but I just wanted to mention it again, since it’s a fairly common oversight.

 

Brent

@Brent Sorrentino: Thanks for the reply! The music is playing on a single dedicated channel, but I am indeed using a channel fade. Everytime I leave a scene, I’m fading out all audio:

 

audio.fadeOut({channel=0, time=fadeLength})

 

I just looked at the API reference, and it says that the value is persistent, and it’s my responsibility to reset my audio levels. So it looks like my function to reset the volumes every time I enter a new scene is actually the right way to do it, if I want to fade everything out when I leave a scene. Now I understand what’s going on.

 

Thanks a lot for the help!

 

  • David

Well, I have to search through all my project codes because many of them are generated code by third party tool.

Thanks Brent for the help.