Preloading Large Amount of Audio Files

Hello everyone,

I'm working on an interactive fiction game that contains approximately 450 individual voice clips. I've tried preloading all of the files in main.lua using audio.loadStream, but I receive a "failed to create audio sound" error after about 100 clips every time.

I can preload all of them using audio.loadSound in the simulator, but of course that takes a while to complete, and it crashes when testing on my iPhone 3G.

Lastly, I've also tried preloading the clips for each individual chapter on each chapter cutscene, but I haven't been able to get that method to work.

Any suggestions or plugins that I could utilize?

Thanks,

Skyler

Generally voice clips are used infrequently and take up lots of memory so you shouldn't try to preload them all.

For voice clips, continue to use audio.loadStream, but instead of preloading everything, try loading and playing them on demand and call audio.dispose after each sound finishes playing to release the resource.

Update: It appears that some of my other code was interfering with the stream, but I managed to get it working now, thanks!

Thanks for the speedy response! I just tried this code for the first voice clip:

1
2
3
v0001 = audio.loadStream( "voice/00-001.mp3" )
vChannel = audio.play( v0001, { channel=1, loops=0 }  )
audio.dispose( v0001 )

You must not call dispose until the sound finishes playing. (Sorry, current limitation we are aware of.) Bad things may happen with the above code. Use onComplete to help here.

Not sure about the warning, but on Android, sounds may not be in subdirectories and may only start with letters, contain only alphanumeric characters or underscore and may not be Java keywords.

Thanks for the heads up. I'll go ahead and change the naming scheme to compensate for the Android file rules.

views:1620 update:2011/9/30 9:15:39
corona forums © 2003-2011