Storyboard: Unloading sounds

Hi all, I’m building a ‘guess the sound’ type quiz at the moment.

I’m currently using

sound = audio.loadStream(“mysound.mp3”)

I’m also using interim scenes, to make sure the scenes are detroyed properly in order to avopid memory leak, however, when I test on a device (iOS 7 / iPhone 5). The sounds start underperforming, the longer my game goes on, crackling, poor buffering etc.

I can only assume that the sounds aren’t unloading properly… Those of you who have used storyboard will know that according to the ‘template’, there is a bit in the SceneMoveOff ‘part’ along the lines of;  “INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.”

This filled me with hope, but I’ve never found a tutorial, bit of code, or resource, that shows me how to properly unload a sound in this part of the code. Can anyone help?

Regards

Mark

This one is a good one:

http://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/

but I am still having problems with this issue as well.

Here is how I am doing it. But I am having problems when you go back to the menu page and start over. About half way

back though my eBook the narration stops playing. No console errors or anything! Frustrating.

[lua]

  
            
local narration = audio.loadStream ( “narration/narrationPage01.mp3”  )
local backgroundSound = audio.loadStream(“sfx/sfxPage01.mp3”);

    

------------Reset Audio------------------------------    

local function resetNarration(event)
    if event.completed == false and event.phase == “stopped” then
        audio.setVolume ( 1, {channel=1 })
        audio.rewind (narration)
    end
        print(“Narration Has Finished on Channel:” , event.channel )
end

local function resetBackgroundSound(event)
    if event.completed == false and event.phase == “stopped” then
        audio.setVolume ( 1, {channel=2 })
        audio.rewind (backgroundSound)
    end
end

    ----- Play Audio Clips --------------
            
                        
    
local function playNarration()

        audio.play(narration,
        {
        channel=1,   
        loops=0,  
        onComplete=resetNarration } )

    
end    
    
    
local function playBackgroundSound()
    if myData.audioCanPlay then
        audio.play(backgroundSound,
        {
        channel=2,   
        loops=0,  
        onComplete=resetBackgroundSound} )

    end
    
end    
        
playNarration()
playBackgroundSound()
 

[/lua]

Good luck!

This one is a good one:

http://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/

but I am still having problems with this issue as well.

Here is how I am doing it. But I am having problems when you go back to the menu page and start over. About half way

back though my eBook the narration stops playing. No console errors or anything! Frustrating.

[lua]

  
            
local narration = audio.loadStream ( “narration/narrationPage01.mp3”  )
local backgroundSound = audio.loadStream(“sfx/sfxPage01.mp3”);

    

------------Reset Audio------------------------------    

local function resetNarration(event)
    if event.completed == false and event.phase == “stopped” then
        audio.setVolume ( 1, {channel=1 })
        audio.rewind (narration)
    end
        print(“Narration Has Finished on Channel:” , event.channel )
end

local function resetBackgroundSound(event)
    if event.completed == false and event.phase == “stopped” then
        audio.setVolume ( 1, {channel=2 })
        audio.rewind (backgroundSound)
    end
end

    ----- Play Audio Clips --------------
            
                        
    
local function playNarration()

        audio.play(narration,
        {
        channel=1,   
        loops=0,  
        onComplete=resetNarration } )

    
end    
    
    
local function playBackgroundSound()
    if myData.audioCanPlay then
        audio.play(backgroundSound,
        {
        channel=2,   
        loops=0,  
        onComplete=resetBackgroundSound} )

    end
    
end    
        
playNarration()
playBackgroundSound()
 

[/lua]

Good luck!