I’m fully aware I could use FMUSIC_SetLooping, except for one problem. You see, FMOD supports only two loop modes: once or infinite. My ST series library has support for three modes: once, counted, or infinite. Counted mode essentially means the user can specify how many times to repeat the song. Because of this, my only out was to use a 250ms timer that calls FMUSIC_IsPlaying, and when the song had finished, call FMUSIC_PlaySong again (assuming the loop count hadn’t been reached).
The problem here is a small delay (about 50ms) every time I call FMUSIC_IsPlaying. Because of this, realtime graphics would be jerky, and so would moving a window around or moving a volume slider (in the case of my miniplayer). To see this problem in action, download the ST series miniplayer, play a MIDI file, then drag the window around the screen with the mouse button down… you’ll see how jerky it is.
http://invis.free.anonymizer.com/http:/ … player.zip
(file is around 450 KB)
That would work, but the problem here is that the FMUSIC_GetBlahBlahBlah functions don’t work with MIDIs–they always return zero. I have no choice but to use IsPlaying, either way.
[b:428v3fkk]edit[/b:428v3fkk] Turns out I could have used FMUSIC_IsFinished all along. IsFinished doesn’t cause any delay, and works fine as long as I stop the song before playing it again (IsFinished stays set even after a loop, the docs say it flat out. If I stop it, the flag is reset).
How about setting the loop for infinite, then doing a “Get Position” poll on
your update. Keeping a variable (either a class var, or a static) or can then
test if last_position > new_position if so increment loop count.
The only problem is that there’ll be potentially a 250ms gap (using your timer value)
for stopping once the loop count is high enough, which could mean
that the sound could play the first 250ms before being stopped.
Don’t know if that would be better than polling FMUSIC_IsPlaying, but
maybe worth a try.
Please login first to submit.