reserve_voices(3alleg4)

✨ reserve_voices ✨

okay so bestie, you're in the Allegro manual and this is reserve_voices(3alleg4) β€” like, the Allegro game programming library's very own "hey drivers, save me some voices" function πŸ’–


🌸 SYNOPSIS 🌸

#include <allegro.h>

void reserve_voices(int digi_voices, int midi_voices);

πŸŽ€ DESCRIPTION πŸŽ€

Call this function to specify the number of voices that are to be used by the digital and MIDI sound drivers respectively. yes, one number for digi, one for MIDI, they're separate, periodt ✨

⚠️ This must be done _before_ calling install_sound(). Like, before before. Not during, not after. BEFORE. πŸ’…

And if you reserve too many voices? 😭 Subsequent calls to install_sound() will fail. It's giving "you asked for too much and now nobody's eating".

How many voices are actually available depends on the driver, and ngl in some cases you will actually get more than you reserve. Examples, bestie, stay with me:

  • the FM synth drivers will always provide 9 voices on an OPL2 and 18 on an OPL3
  • the SB digital driver will round the number of voices up to the nearest power of two

Slay. Free voices. We love a little bonus πŸ¦‹

Pass negative values to restore the default settings β€” it's the reset button, the "never mind, forget I said anything" of voice reservation πŸ™ˆ

Also you should be aware that the sound quality is usually inversely related to how many voices you use. So like... more voices β‰  more better. The vibe check says: don't reserve any more than you really need. πŸ‘‘


πŸ’« SEE ALSO πŸ’«


and that's the whole page, bestie!! 🫢 this little love letter to voice reservation is brought to you by Allegro, version 4.4.3, and yes she ate πŸ’…πŸŽ€πŸŒΈ not me being obsessed with a sound driver API... anyway, mwah, go reserve responsibly ✨