al_register_sample_loader(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_register_sample_loader πŸ’–

okay bestie, welcome to the Allegro 5 API β€” yes that's 3alleg5, that's the manual we're in, and today we're talking about teaching Allegro how to open your weird little audio file format. let's go πŸŽ€


✨ NAME ✨

al_register_sample_loader β€” the glow-up that lets al_load_sample handle a brand new file extension, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro5/allegro_audio.h>

bool al_register_sample_loader(const char *ext,
   ALLEGRO_SAMPLE *(*loader)(const char *filename))

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea πŸ“ β€” you call this and you're basically registering a handler for al_load_sample(3alleg5). the function you hand over? that's the one that's gonna be in charge of loading sample files that have the extension you picked.

the extension you pass in should include the leading dot (the . character). and the way it gets matched? case-insensitively. so like .WAV and .wav are the same vibe, she doesn't care ✨

the loader argument can be NULL β€” and that's you unregistering an entry, lowkey a breakup πŸ’”

as for the return value: it gives you back true on success, false on error. and heads up πŸ‘‘ β€” it also returns false if you try to unregister an entry that doesn't even exist. yeah. nothing to cancel, bestie 😭

ngl that last one is important: unregistering something that was never registered = false. don't be surprised, it's not a bug, it's just honest fr fr.

🌈 SEE ALSO 🌈


and that's the whole page, bestie 🫢 β€” this was pulled straight from the Allegro reference manual, and yes, al_register_sample_loader(3alleg5) is the manual name, so if you ever need to cite her, that's the one πŸ’œ go forth and load your samples πŸ’…βœ¨

πŸ“¦ where this page comes from