Looping music with SDL_mixer

Started by
0 comments, last by Zakwayda 15 years, 3 months ago
I've run into some problems with playing looped music tracks in SDL_mixer, so I thought I'd post here to see if anyone had any suggestions. I'm currently playing the tracks via Mix_PlayMusic() and have observed that with both .ogg and .wav files, there's a timing glitch at the loop point. With smaller buffer sizes (e.g. 1024), it comes out as a slight 'pop'. With larger buffer sizes, the glitch becomes more and more noticeable. The tracks loop fine when played back via Mix_PlayChannel(). I'm assuming this is because the sound system decompresses and stores the data on load, rather than streaming the data during playback. My current plan is to switch over to playing music through the sound system rather than the music system, so that the tracks will loop correctly. This does have a few drawbacks though, so I thought I'd ask here first to see if anyone had any other suggestions. Is there any way around these looping problems when using Mix_PlayMusic()? Or are they unavoidable?
Advertisement
Just posting a follow-up, in case anyone comes across this thread in the future.

I tried some different search terms and found this thread, which I'd missed the first time around. It discusses the problem in detail, and seems to suggest that SDL_mixer just isn't capable of looping streamed audio seamlessly (at least not without modification).

I'm looking into trying to patch the SDL_mixer source code, but if anyone knows of an easier solution, please let me know! :)

This topic is closed to new replies.

Advertisement