Way to speed up the loading of game music?
BlitzMax Forums/BlitzMax Programming/Way to speed up the loading of game music?
| ||
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 |
| ||
You could try this: http://www.blitzbasic.com/codearcs/codearcs.php?code=1757 |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
Well, I've used MaxMod before with IncBin'd variable bitrate OGGs, AND wrapped with Reflexive's DRM software and everything worked perfectly. |
| ||
I'm using fmod 3.75 for streaming... |
| ||
FMOD isn't a free (or even cheap) solution though, is it? |
| ||
Free for free stuff, cheap for shareware... I stopped reading after that... |
| ||
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. |
| ||
Been some times since I looked at FMod but if I recall correctly it was $100 for a shareware license. |
| ||
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. |
| ||
"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. |
| ||
Because they have to be uncompressed to play them when you don't stream them. |
| ||
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 |
| ||
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. |
| ||
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. |
| ||
"Because they have to be uncompressed to play them when you don't stream them." Doh! Jeesh... I should have known that one. |
| ||
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? |
| ||
I'm sure MaxMod can stream from incbin? |
| ||
Thanks Brucey, I'll give that a try :) |
| ||
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? |