register_sample_file_type(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ register_sample_file_type(3) ✨

okay bestie, welcome to the Allegro manual πŸŽ€ this one lives in the Allegro game programming library, and it's lowkey a glow-up for your sample loading game πŸ’…


πŸ’– NAME πŸ’–

register_sample_file_type β€” registers custom loading/saving sample routines. Allegro game programming library. no cap, that's the whole vibe πŸ¦‹


🌸 SYNOPSIS 🌸

#include <allegro.h>

void register_sample_file_type(const char *ext, SAMPLE *(*load)(const char *filename), int (*save)(const char *filename, SAMPLE *spl));

✨ DESCRIPTION ✨

so basically πŸ‘‘ this function tells load_sample() that there's a new sample file type in town, and it hands over the routines that read and write samples in that format. the way that works is you give it the extension and the two function pointers, and either function may be NULL β€” like, if you only wanna load and never save, that's totally fine, she's flexible 🫢

fr fr, here's the example, copy-paste ready and iconic:

SAMPLE *load_mp3(const char *filename)
{
   ...
}

   register_sample_file_type("mp3", load_mp3, NULL);

see how load_mp3 goes in the load slot and NULL slides into save? main character energy 🌈 literally that simple.


πŸ¦‹ SEE ALSO πŸ¦‹

iykyk, go read those next bestie πŸ’œ


okay that's the page!! this was brought to you by Allegro, version 4.4.3 β€” periodt, mwah πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from