play_midi(3alleg4)

πŸŽ€ play_midi β€” the Allegro manual, but make it cute πŸŽ€

okay bestie, welcome to the Allegro manual πŸ’– this one lives in section 3 (3alleg4), it's part of the Allegro game programming library, and today we're talking about play_midi β€” the function that makes your game go 🎡✨


✨ NAME ✨

play_midi β€” starts playing the specified MIDI file. Allegro game programming library. no cap, that's literally it, and it's iconic for it πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int play_midi(MIDI *midi, int loop);

she's short, she's simple, she takes a MIDI * and an int, and she EATS πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: play_midi starts playing the specified MIDI file, and the first thing it does β€” before anything else β€” is stop whatever music was previously playing. no overlap, no messy transitions, one track at a time, periodt πŸ’€

Then there's the loop flag, and bestie this is the whole personality of the function:

  • if loop is set to non-zero, the data will be repeated until replaced with something else β€” it just goes and goes and goes, main character energy πŸ”
  • otherwise it will stop at the end of the file, and that's that, a lil finite bop 🎢

And the sneaky one: passing a NULL pointer will stop whatever music is currently playing. that's right, NULL is your "shut it down" button, she's giving silence as a feature πŸ™ˆ


πŸ’œ RETURN VALUE πŸ’œ

Returns non-zero if an error occurs 😭 and ngl the docs are very honest about when that might happen: this may happen if a patch-caching wavetable driver is unable to load the required samples.

…or at least it might in the future when somebody writes some patch-caching wavetable drivers :-)

yes the manpage really did put a smiley in there. we love a humble king 🫢

🌈 SEE ALSO 🌈

the whole friend group, go say hi πŸ’–


and that's the page, bestie πŸŽ€ this was Allegro version 4.4.3, and the page is play_midi(3alleg4) β€” mwah, go make some music, iykyk βœ¨πŸ’…πŸ¦‹