Loading Ogg files faster
BlitzMax Forums/BlitzMax Beginners Area/Loading Ogg files faster
| ||
When I loaded an ogg Music file with FreeAudio it took around ~1500 millisecs And it was compressed in quality and in the kbit rate to 112 kb/s The same wav file took around ~60ms. Now, 1500 msecs is too long, and I dont like 30 mb wav files, so whats the solution on this? |
| ||
There's no solution as far as I know. ogg has to be decoded and this takes time, while the WAV has not to be decoded as it is RAW pcm audio. Take into account that the beneffits of OGG are mainly on deployment of the game, as both will take the same amount of RAM when being used (well, ogg a bit more as it will store also the coded data stream during load). You can split the ogg into smaller ones, load one after the other (while refreshing the sreen to avoid making the game look hung) and you can later join them into a new sound object. This will be a bit slower, but can be used to make this process responsive... My two cents |
| ||
Can you preload the ogg file into ram, like a bank or something, and then load the ogg from there? |
| ||
If that's faster then i would do it (i haven't worked with banks until now) The question is how fast is the preloading because it still has to decode the ogg file (and my game will at least have 20 oggs). The splitting thing sounds interesting, but I'd prefer the direct loading if possible. Is it possible to partly load an ogg stream? I mean loading a part of the ogg file and then playing the part loaded while loading the rest in the background. |
| ||
Just one more option, multithreaded loading. Personally I'd go with imaginaryhuman's method of doing a ram load If possible and if that was too slow then experiment with threading so you can do other setup while you load. Yet another option might be another sound lib rather than the built in methods. One that could stream the data... |
| ||
Streaming audio is your best option. Search for MaxMod2. |
| ||
I wrote about the same thing, see GFK answer on http://www.blitzbasic.com/Community/posts.php?topic=90852#1033753 That is the workaround and it pretty fast to load up. |
| ||
That is the workaround and it pretty fast to load up. Pretty fast is an understatement :D A 7 minute piece( 7.9 MB, 160 kbps ) took 60 ms to load, the one from my intial post around 10 ms Thanks a lot. However, when using MaxMod2 in DebugMode it ends (so after the app ends) with a segmentation fault (Release is doing fine) Import maxmod2.rtaudio Import maxmod2.ogg SetAudioStreamDriver("Maxmod rtaudio") Graphics 400,300,0 ms = MilliSecs() Local bank:TBank = LoadBank("music.ogg") Print MilliSecs()-ms Local music:TChannel = PlayMusic(bank) WaitKey() End I have had some compiling problems with maxmod2 and inserted a #include <stdio.h> at the top (in file.cpp) and then it compiled fine. Ubuntu 10.04, GCC ad G++ version 4.4.3 |
| ||
Just tested the above code here and it works perfectly (Blitzmax 1.41, MaxMod2 1.07). I'm using Windows 7, though. Does Blitzmax default to FreeAudio on Linux? I'm sure that MaxMod only supports FreeAudio and OpenAL. |
| ||
Magically my problem disappeared. I haven't changed anything but after trying to recompile it now also works in debug mode. Thanks for helping, this is really a great forum. |
| ||
The problem I had which suddenly crashed the application in Release Mode now appeared again. And the problem seams to be related to banks, because when I use Local music:TChannel = PlayMusic("music.ogg") it plays fine. Btw, its also a LOT faster this way. Takes 1ms to load on my machine in contrast to the ~50ms before (an to the 1500ms before -.-). |