al_reserve_samples(3alleg5)

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

✨ NAME ✨

al_reserve_samples β€” it's giving Allegro 5 API, bestie πŸ’–

This page lives in the allegro5 manual, and yes we're about to make audio setup actually make sense. Periodt.


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro5/allegro_audio.h>

bool al_reserve_samples(int reserve_samples)

πŸ’… DESCRIPTION πŸ’…

Okay so here's the vibe: this function reserves a number of sample instances and attaches them to the default mixer. That's it, that's the whole job, and she does it flawlessly 🫢

But wait, there's lore. If no default mixer is set when you call this function, then it will create one and attach it to the default voice. And if no default voice has been set? Yeah, it, too, will be created. Not me building the whole audio pipeline from scratch, main character energy fr fr πŸ‘‘

⚠️ Okay listen up because this part is important: if you call this function a second time with a smaller number of samples, then the excess internal sample instances will be destroyed. That means some sounds will stop and some instances returned by al_lock_sample_id(3alleg5) will be invalidated. So like… don't be out here shrinking your reserves and then acting surprised when your audio ghosts you πŸ˜­πŸ’€

This diagram illustrates the structures that are set up:

                                             sample instance 1
                                           / sample instance 2
      default voice <-- default mixer <---         .
                                           \        .
                                             sample instance N

Look at that little family tree, I'm obsessed 🌸 The default voice feeds the default mixer, and the default mixer parents all N sample instances. Iconic structure, no notes.

Returns true on success, false on error. And bestie, al_install_audio(3alleg5) must have been called first β€” that's not optional, that's the prerequisite, iykyk ✨


πŸ¦‹ SEE ALSO πŸ¦‹


And that's the whole page, bestie! This was the Allegro reference manual serving up al_reserve_samples(3alleg5) πŸ’œ Go forth and reserve those samples, you've absolutely got this πŸŽ€βœ¨

πŸ“¦ where this page comes from