midi_msg_callback(3alleg4)

✨ NAME ✨

midi_msg_callback, midi_meta_callback, midi_sysex_callback β€” bestie, these are the hook functions that let you intercept MIDI player events πŸ’… they're part of the Allegro game programming library, and yes we are in section 3alleg4 of the Allegro manual, iykyk πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

extern void (*midi_msg_callback)(int msg, int byte1, int byte2);

extern void (*midi_meta_callback)(int type, const unsigned char *data,
int length);

extern void (*midi_sysex_callback)(const unsigned char *data, int
length);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so these are hook functions that let you intercept MIDI player events πŸ‘‘ the way that you get to just… reach in and grab them. Obsessed.

Set any of them to anything other than NULL and boom πŸ’₯ β€” that routine gets called for every single MIDI message, meta-event, and system exclusive data block respectively. One function per event type, all three doing their own little thing, no cap.

⚠️ the tea you NEED to know: these run in an interrupt handler context. So like, all the code and data they touch has to be locked πŸ”’ and they must not call any operating system functions. Periodt. Don't try it. 🚫

ngl the move here is: in general you just use these routines to set some flags 🌈 and then respond to them later in your mainline code. That's it. That's the vibe check. Set the flag, dip out, deal with it in mainline. Clean, iconic, no drama. πŸ’–


πŸ’œ SEE ALSO πŸ’œ

  • play_midi(3alleg4) β€” go read it bestie, it's the whole point of this little callback party 🫢

alright my love, that's the whole page ✨ this came out of the Allegro manual, and it's documented for version 4.4.3 β€” so if your Allegro is a different era, double check, okay? 😭 mwah, go intercept some MIDI, you're doing amazing πŸ’…πŸŽ€πŸ¦‹