al_set_sample_instance_pan(3alleg5)

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

πŸ’– al_set_sample_instance_pan β€” Allegro 5 API πŸ’–

okay bestie, so we're in the Allegro 5 API today and this one is genuinely one of my faves because it's the "which speaker tho" button for your audio. let's get into it 🎧✨


✨ SYNOPSIS ✨

#include <allegro5/allegro_audio.h>

bool al_set_sample_instance_pan(ALLEGRO_SAMPLE_INSTANCE *spl, float val)

like yes, one function, two args, we love a low-effort icon πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so you pass in your sample instance spl and a float val, and it sets the pan value on that sample instance. that's it. that's the whole vibe.

and the val numbers? lemme break it down because it's giving stereo geometry:

  • -1.0 β€” plays the sample only through the left speaker 🫢
  • +1.0 β€” plays it only through the right speaker πŸ’…
  • 0.0 β€” the sample is centre balanced, dead middle, main character in the middle of the stage πŸ‘‘

and then there's the special value ALLEGRO_AUDIO_PAN_NONE(3alleg5) β€” this one disables panning entirely and plays the sample at its original level. and lowkey important: this will be louder than a pan value of 0.0. like yes it's technically the "no notes" option and it goes harder. not a bug, just facts ✨

πŸ™ˆ note: panning samples with more than two channels doesn't work yet. like bestie it's giving unfinished business, so don't come for me if you try it with your fancy multichannel stuff.

🌈 what it gives back

  • returns true on success πŸ’–
  • returns false on failure 😭
  • and it will fail if the sample instance is attached directly to a voice. no cap, that's a hard no.

πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page fr fr. this little gem lives in the Allegro reference manual (the al_set_sample_instance_pan(3alleg5) page, if you're keeping track πŸ“). go pan something, you got this πŸ§šπŸ’œ

πŸ“¦ where this page comes from