Looping .ogg files smoothly. Is it possible?

Blitz3D Forums/Blitz3D Programming/Looping .ogg files smoothly. Is it possible?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

WAV files don't auto-loop! At least they never have with me and I've been coding in Blitz for 3 years! Is there anything in the WAV file format that can force them to loop - I don't know, I'm just asking.

I've not had any trouble with OGG files myself when using LoadSound/LoopSound. There is an initial pause when you first load them (which is when it first decompresses), but I've not experienced a long pause when it loops. Is it possible you're reloading the music?

An alternative to LoadSound/LoopSound is to use PlayMusic. This streams the music from your hard drive and is decompressed as it plays, which may help. The downside is that you have to keep checking if the music has finished playing and then start it up again.

Global musicChannel=PlaySound("music.ogg")

While Not KeyHit(1)
   ; check music every game loop
  If Not ChannelPlaying(musicChannel) Then
     musicChannel=PlaySound("music.ogg")
  EndIf
Wend

PlaySound also consumes less system memory, whereas loading an OGG file could consume as much as 40MB to 100MB of memory, as the file has to be fully decompressed to play. PlaySound uses a much smaller buffer instead, less than 10MB I think, but don't quote me as I can't remember what the consumption was when I tested the two methods out (it was a while ago).

Hope that was of some use.