PDA

View Full Version : SDL_Mixer: How to tell when music loops?



masonwheeler
14-10-2007, 03:40 PM
How can I tell when the music I'm playing on infinite looped mode with SDL_Mixer has looped? I tried Mix_HookMusicFinished, but that didn't work; apparently it only notifies you when the music stops playing, which it won't do on an infinite loop. Is there another callback function that I missed? If not, is there some coding trick I can use?

Mason

WILL
14-10-2007, 05:15 PM
You could just not set it to infinite loop and hook a procedure to set a flag and restart the track upon stopping. So long as you don't unload the music file I think it could restart almost unnoticed.

The problem of you trying to manually stop the track and having it restart then would easily be averted by putting the restart code under a flag condition. To prevent it from restarting on stopping, you'd simply set the flag to be true.

So this procedure might look something like this


var
MusicLooped: Boolean;

procedure onTrackStop;
begin
if (not disableMusicLooping) then
RestartMusic;

MusicLooped := True;
end;

masonwheeler
14-10-2007, 05:21 PM
I guess that'll work, if it's fast. I'll test it.
BTW, do you happen to know any way to alter the tempo of music being played? There are prebuilt effects for panning and volume, but not one for tempo, and I need a tempo effect. Does anyone know where I could find one?

Mason

WILL
14-10-2007, 06:07 PM
Hmm... unsure. Personally, I have worked with the sdl_mixer a while ago, but never really got too in depth with all of it's functions.

I probably went through all the surface functionality as I do with almost everything new I try out, but I don't recall it being as versatile as it would take to make a fully capable player like WinAmp or anything as complex as that.

To get what you want, some hacking into the innards of the functions might be required.