How to deal with music playing?

Ello all!

I was wondering if anyone has a better plan than the one I am already attempting to carry out with regard to playing music in my game.

What I have right now is all my mp3 tracks stuffed into the resources folder. When the level starts, I do a resource load to nab the song and start playing it.

Whilst it works, the load time is stupid. It literally pauses the whole device as it loads the mp3 from resources into memory. Because of this, I can’t play more than one track during a level - I can only play one track and loop it since no-one wants the action to pause mid-air so that it can load another song!

I would really like to be able to:

a) not have to load the entire song into memory and waste 3-4mb
b) switch tracks on the fly without a HUGE pause in the game as it shifts it around memory

Anyone got any clues on how to accomplish this?

Thanks!

Yea, that’s one reason why we had to remove music from game play just to keep the frame rate up, load times down and not to crash every three minutes… :roll:

Sorry to hear that, GI_JOEJK. For a device that is primarily a music player, it’s mind blowing that it is such a difficult task to accomplish well!

Maybe moving the audio out of Unity and into Cocoa is going to be the only option, then?

Has anyone tried writing an external sound system?

Since Unity has to load ALL the sound effects into memory at once (or suffer huge lag as it grabs them from resources) … I wonder if there is a better way through Obj-C?

Would be really sweet to not have to load everything into memory (since we’re all suffering from tiny memory of death syndrome!)…

GAH!

From http://blogs.unity3d.com/2009/04/06/unity-iphone-roadmap/ :

–Eric

Thanks for the reply Eric, but it’s not helpful. It’s great that it is in the roadmap, but what am I supposed to do NOW!??

1.5 came and went without it and I don’t see compressed audio streaming coming anytime soon … so is there any actual solution, or just an ‘abandon what you want to do and come back later’ ?!

EDIT: I just read this back and it sounds grumpy - I’m not grumpy at you Eric :slight_smile:

Load all the music at the beginning of the game during a load screen.

I have four different songs in my game, and can rotate between them without ANY slowdown.

Thanks for the reply … yeah, that’d be nice if I wasn’t already running out of memory and my mp3s weren’t 3-4mb each :frowning:

Loading them all at the start = iphone memory death :frowning:

Gotcha.

I had a similar problem with art assets, in the end I decided a little loading between scenes was better than the potential crash at the beginning of the game.