Way to speed up the loading of game music?

BlitzMax Forums/BlitzMax Programming/Way to speed up the loading of game music?

Arowx(Posted 2008) [#1]
Hi all, just incbin'ed some extra music tracks to my game for the release version, only to find that the 'delayed' loading process now takes nearly a minute to load incbin'ed .ogg music tracks (6 tracks totaling about 18 Mb in total avg 2Mb) via the LoadSound() method.

So is there a way to speed up the loading process e.g.

Is loading from external file faster?
Would zipping up the tracks speed up the initial loading?
Could I use a thread to load the music in the background?
Would another format work faster?
Is there another approach to this that would work?

Any and all help welcome!

Regards

Merx


rs22(Posted 2008) [#2]
You could try this: http://www.blitzbasic.com/codearcs/codearcs.php?code=1757


deps(Posted 2008) [#3]
Another approach would be to use a module that supports streaming. Not sure if you can stream from an incbin'ed file, but you can from external files. This way you won't need to load the entire file and it will save some memory.


GfK(Posted 2008) [#4]
6 tracks totaling about 18 Mb in total avg 2Mb
You're loading them all at once?

You know that's going to suck up around 180MB of resources, right? Might want to consider REDi's MaxMod for streaming audio.


Gabriel(Posted 2008) [#5]
To stream music, all you usually need is a pointer and the length of the data, so I would imagine streaming from an IncBin'ed song would work fine. You might also try loading it directly into a bank and streaming it from there. The initial loading period should be less as you are not decompressing it as you load it, as you are when loading it as a sound.


GfK(Posted 2008) [#6]
Well, I've used MaxMod before with IncBin'd variable bitrate OGGs, AND wrapped with Reflexive's DRM software and everything worked perfectly.


Grisu(Posted 2008) [#7]
I'm using fmod 3.75 for streaming...


GfK(Posted 2008) [#8]
FMOD isn't a free (or even cheap) solution though, is it?


Brucey(Posted 2008) [#9]
Free for free stuff, cheap for shareware... I stopped reading after that...


Gabriel(Posted 2008) [#10]
It's not really cheap for shareware. The rules on what constitutes shareware are very strict, and most shareware won't comply, so you'd end up needing a commercial license. Bass is pretty cheap though.


deps(Posted 2008) [#11]
Been some times since I looked at FMod but if I recall correctly it was $100 for a shareware license.


Gabriel(Posted 2008) [#12]
Been some times since I looked at FMod but if I recall correctly it was $100 for a shareware license.

That only applies to games selling for less than $10, which would rule out all portal games.


MGE(Posted 2008) [#13]
"6 tracks totaling about 18 Mb in total avg 2Mb.."

"You know that's going to suck up around 180MB of resources, right?"

Could someone explain why 18mb becomes 180mb when dealing with sound files? Thanks.


Gabriel(Posted 2008) [#14]
Because they have to be uncompressed to play them when you don't stream them.


Russell(Posted 2008) [#15]
Streaming would speed up the load time a bit, but then you wouldn't have the music protected from piracy, etc. I wonder if there is an encrypted music format....

Russell


Gabriel(Posted 2008) [#16]
Streaming would speed up the load time a bit, but then you wouldn't have the music protected from piracy, etc

Sure it would. Stream it from memory as I suggested above, or straight out of an encrypted zip archive. I know the latter works because I'm doing it, and GFK confirmed he has the former working.


GfK(Posted 2008) [#17]
Streaming would speed up the load time a bit, but then you wouldn't have the music protected from piracy, etc
As I said above, you can still stream audio even if you've used Incbin and DRM software. It also works with Molebox.


MGE(Posted 2008) [#18]
"Because they have to be uncompressed to play them when you don't stream them."

Doh! Jeesh... I should have known that one.


iprice(Posted 2008) [#19]
As I said above, you can still stream audio even if you've used Incbin and DRM software


Have you any code for streaming an incbinned .ogg?


Brucey(Posted 2008) [#20]
I'm sure MaxMod can stream from incbin?


iprice(Posted 2008) [#21]
Thanks Brucey, I'll give that a try :)


Arowx(Posted 2008) [#22]
Excellent I now have the music streaming from incbin thanks to the MaxMod Module's CreateAudioStream(URL) command.

However I have noticed an oddity, when I first startup my game the first track is triggered during the loading screen and then once in the main game loop I have a updateMusic method that checks the myChannel.Playing() status to test when the track completes and start the next one.

Now the first track starts fine whilst the game loads (now a couple of seconds), but once the updateMusic method is called from the main game loop it's call to test if the channel is Playing return's false (???) and the game switches to the next track and which plays fine?

This was not an issue with the previous LoadAudio version, is this a bug in the Streamed audio module?