Hi all
I have a couple of simple questions about handling audio.
I started out having serious problems with my audio but that was inexperience and sloppy code, I’m much better now and have no audio issues, but I do have a couple of gaps in my knowledge on this subject and I’m hoping some nice people here on Corona can give me the answers.
I load all my sounds in a separate module called sfx.lua
In every scene I declare all my audio local and give every channel a handle like so…
local sfx = require(“sfx”)
local backsound = audio.play(sfx.backSound, {loops=-1})
audio.setVolume( 0.6, { channel=backSound } )
I normally stop all the sound in the exit scene with audio.stop()
Then I dispose of all the audio files in the sfx table…
for i = 1, 16 do
audio.dispose(i)
end
Then I delete the package sfx
package.loaded[“sfx”] = nil
My question is this, do I need to nil out all the audio handles like so…
backsound = nil
winsound = nil
…
My logic is because all the handles are local and they are all inside the Storyboard enterScene does not Storyboard nil them out anyway? Also true with local variables and local functions()? :huh:
And another thing I’m concerned about is reserving audio channels…
audio.reserveChannels( 16 )
So far I have 16 sounds in my sfx.lua module and will probably add more.
Is it necessary to reserve a channel for each sound you load?
sfx.backSound = audio.loadSound( “sounds/ambience.ogg”, {channel=5} )
Should I be using .ogg or would .wav be more universally accepted?
Because I give every sound a name in each scene and stop and start them and fade them in and out with their name(handle) not their channel number, would just loading the sounds without channels make any difference?