Using audio.dispose() on long background music tracks?

I have a series of three long (about 5-7 min each) music tracks that play in the background.  I’ve got an audio.dispose() call that happens onComplete, and then the next track plays.  However, I notice a serious performance “halt” when that dispose is called and when the next loadSound() is called.   

Should I simply load all three into memory and forget about the disposing?  That is, if they’re always gonna loop?

thanks

Hi @borderleap,

Are you using “loadSound” or “loadStream”? Music files should almost always be played using loadStream, so the file is loaded gradually instead of all at once.

I suppose you could load all of them into memory (as sounds, not streams) before the game/app starts, but you’d need to test performance of various devices to ensure this doesn’t hit the performance too hard.

Disposal of audio should generally be done only when you’re completely done using the files (i.e. after the level ends, in a non-time-critical point).

Hope this helps,

Brent

Hey Brent, thanks a ton - actually I wasn’t using loadStream but am now :slight_smile:  Will see how the dispose call works with those…  

Hi @borderleap,

Are you using “loadSound” or “loadStream”? Music files should almost always be played using loadStream, so the file is loaded gradually instead of all at once.

I suppose you could load all of them into memory (as sounds, not streams) before the game/app starts, but you’d need to test performance of various devices to ensure this doesn’t hit the performance too hard.

Disposal of audio should generally be done only when you’re completely done using the files (i.e. after the level ends, in a non-time-critical point).

Hope this helps,

Brent

Hey Brent, thanks a ton - actually I wasn’t using loadStream but am now :slight_smile:  Will see how the dispose call works with those…