Sign in to follow this  
Sukasa

Issues with SDL_Mixer skipping when looping OGG files

Recommended Posts

I've spent a few hours at this, and I'm not having much luck. Does anyone have any insight they could offer? I'm using a slightly modified build of the latest SDL_Mixer (Modified such that I can specify a loop point in an audio stream to have it loop from there instead of the beginning of the stream), but in both this modified SDL_Mixer and the original SDL_Mixer, I get a ~1/4 second delay between when the end of the stream is reached and when play resumes (either from the start of the stream, or the loop point in my custom build). Does anyone know anything about how SDL_Mixer works I could use to fix the skipping problem?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sukasa
I've spent a few hours at this, and I'm not having much luck. Does anyone have any insight they could offer?

I'm using a slightly modified build of the latest SDL_Mixer (Modified such that I can specify a loop point in an audio stream to have it loop from there instead of the beginning of the stream), but in both this modified SDL_Mixer and the original SDL_Mixer, I get a ~1/4 second delay between when the end of the stream is reached and when play resumes (either from the start of the stream, or the loop point in my custom build). Does anyone know anything about how SDL_Mixer works I could use to fix the skipping problem?
I can't comment on the modification that you made (since I don't know the details), but as for the general problem you mention, I can confirm your observation.

I spent a long time on this myself, and after doing a lot of research came to the conclusion that SDL_mixer isn't able to loop .ogg files seamlessly. (There's actually a entry on this in the SDL_mixer Bugzilla log; it looks like seamless looping is a feature they just never got around to adding.)

After messing around with this for a while, I finally switched to streaming the music files myself (using the Vorbis library) and feeding the audio to SDL_mixer via the music mixing callback. An additional benefit of this was that in addition to seamless looping I also got seamless track queueing, which can be useful in terms of linking different parts of an arrangement together (e.g. intro, body, etc.) without introducing noticeable audio artifacts.

If there's a way to get SDL_mixer to loop .ogg files seamlessly using the built-in music playback functions I'd certainly be interested to know about it, but as far as I know, it's not possible.

Share this post


Link to post
Share on other sites
My edit was simply an extra property in the _Mix_Music struct that could be set (and defaulted to 0), and in halt_or_loop_music, the call the restarted the music simply used music->loop_start (my extra member of the struct) as the start position instead of 0.

Share this post


Link to post
Share on other sites
My edit was simply an extra property in the _Mix_Music struct that could be set (and defaulted to 0), and in halt_or_loop_music, the call the restarted the music simply used music->loop_start (my extra member of the struct) as the start position instead of 0.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this