load_sample(3)
β¨ load_sample(3) β the Allegro manual, but make it cute β¨
okay bestie, welcome to the Allegro manual π this one's about load_sample(3), and it's genuinely one of the most useful little gremlins in the whole audio toolbox, no cap.
πΈ NAME πΈ
load_sample β loads a sample from a file. Part of the Allegro game programming library π
π¦ SYNOPSIS π¦
#include <allegro.h>
SAMPLE *load_sample(const char *filename);
π DESCRIPTION π
So like. This function grabs a sample out of a file and hands it to you, wrapped up all nice. It's giving versatile honestly, because it handles a whole bunch of formats:
- mono and stereo WAV files π§
- mono VOC files
- in 8-bit or 16-bit formats β¨
- plus literally any other format that some function you registered with
register_sample_file_type()knows how to deal with π
Example, because seeing it is believing:
SAMPLE *sample = load_sample(user_input);
if (!sample)
abort_on_error("Couldn't load sample!");
look at her. iconic. π
β RETURN VALUE β
You get back a pointer to the SAMPLE, or NULL if something went wrong π (yes, the classic NULL-on-error situation, we've all been there).
π«Ά bestie please, remember to free this sample later to avoid memory leaks. Don't leave her hanging, that's not main character energy.
π SEE ALSO π
destroy_sample(3)load_voc(3)load_wav(3)play_sample(3)save_sample(3)register_sample_file_type(3)exsample(3)
Allegro, version 4.4.3, and the page date β all of it came from the load_sample(3) page in the Allegro manual, and we're shouting them out at the very end like the icons they are π mwah, go load some samples, you got this π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms