midi_loop_start(3alleg4)

πŸ’– midi_loop_start πŸ’–

ok so bestie, we're in the Allegro manual, and today's hyperfixation is midi_loop_start (plus its ride-or-die twin midi_loop_end). this is a page from the Allegro game programming library, and it's short but it is important, so lock in 🫢


✨ SYNOPSIS ✨

#include <allegro.h>

extern long midi_loop_start;

extern long midi_loop_end;

like. two whole globals. that's the whole vibe. two longs just out there living their lives πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so these two are the loop start and end points, and they get set by the play_looped_midi() function. that's it, that's their whole origin story. play_looped_midi() sets them, you read them, everyone's happy.

here's the part where you actually have to pay attention though 😭

  • you can safely alter these while the music is playing. yes, live. mid-song. main character behaviour, honestly.
  • BUT you gotta make sure they're always set to sensible values, and by sensible we mean start < end. no cap.
  • if you're changing both of them at the same time, you must alter them in the right order, because a MIDI interrupt could literally happen in between your two writes. the way that a MIDI interrupt can just sneak in there mid-write?? πŸ’€
fr fr, be careful with the ordering here. if an interrupt lands between your two writes and the pair is momentarily nonsense, that's on you, bestie.

and the cherry on top: setting either of these values to -1 represents the start and end of the file respectively. so -1 for start = beginning of the file, -1 for end = end of the file. iconic little shortcut, ngl πŸ“


🌈 SEE ALSO 🌈


and that's the page!! tysm for reading, go forth and loop your MIDI responsibly πŸ’œ

this little love letter to you came from Allegro version 4.4.3 β€” mwah, bye bestie 🧚✨