Jump to content
  • Advertisement
Sign in to follow this  
Rokkuman

Looping music for games --SDL_Mixer

This topic is 3627 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How, using SDL_Mixer, would I make it so that a track will play once in its entirety, and then infinitely loop after the "intro" of the song has played seamlessly? There seems to be nothing built in for this, and I can find no such solution on Google. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Rokkuman
How, using SDL_Mixer, would I make it so that a track will play once in its entirety, and then infinitely loop after the "intro" of the song has played seamlessly? There seems to be nothing built in for this, and I can find no such solution on Google. Thanks in advance.
There was another thread on the exact same topic in this forum at some point in the past, but I don't have a link. You might try searching the forum archives for 'SDL_mixer loop' or something of that sort.

The short answer is that SDL_mixer has no built-in support for this, so you'll have to do it yourself using your own code and the SDL_mixer callbacks. Personally, I haven't had much luck with looping music in SDL_mixer (it seems to 'hitch' intermittently at the loop point - maybe due to rebuffering?), but maybe I've just been doing something wrong...

Share this post


Link to post
Share on other sites
It was probably my thread and I've come back almost a year and a half later for revenge as I have still not yet figured out how to do what people have been doing in some way, shape, or form for like 30 years.

Although kavendek's belated reply:
Quote:

This thread is kind of old, but in my search for something else, I accidentally found this thread and it piqued my interest.

It seems like the methods of going back and looping from some predetermined point in the music is a much more difficult way of doing this. Wouldn't it be a lot less error prone and simpler to just have two separate music files, one for the intro, and one for the part that loops? You can then make it so that your on-finished callback will just loop the loop-able track, none the wiser that the initial music call actually was playing the intro track. Then all you have to be concerned with is making that one looping track loop well. This could even be generalized to any set of intro/loop music tracks, through some cooked-up naming convention.

Just my two cents!


is certainly an interesting solution. I've thought of this myself, but is there any way to pull this off with NO seams that are caused by anything other than the music itself?

Share this post


Link to post
Share on other sites
If you don't need to use a streamed file format then it is much easier to loop it. If your music was in .XM format it would loop without effort. Are you using MP3 or OGG? That may be the problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!