voice_set_playmode(3)

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

πŸ’– voice_set_playmode β€” the Allegro manual, but make it make sense πŸ’–

okay bestie, gather round, because this one is genuinely so useful and also lowkey the reason your game audio doesn't sound like a broken washing machine 🫢

✨ NAME ✨

voice_set_playmode β€” adjusts the loop status of the specified voice. it lives in the Allegro game programming library, and it's giving "small function, huge main character energy" πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

void voice_set_playmode(int voice, int playmode);

that's it. two ints. one dream. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So basically, voice_set_playmode adjusts the loop status of the voice you point it at. and the iconic part? you can do this while the voice is already playing. not me being able to mess with a sound mid-playback 😭

the classic move: you start a sample in looped mode (having set the loop start and end positions to the appropriate values first, bestie, don't skip that part), and then later you clear the loop flag when you want the sound to actually end. and when you do that? the sample keeps going past the loop end, plays the subsequent part of the sample, and finishes in the normal way. no cap, it just gracefully exits like a queen. πŸ‘‘

the playmode parameter is a bitfield, and it contains the following values:

  • PLAYMODE_PLAY β€” plays the sample a single time. this is the default if you don't set the loop flag. one and done, no repeats, no encore. πŸ’€
  • PLAYMODE_LOOP β€” loops repeatedly through the sample, jumping back to the loop start position upon reaching the loop end. it's giving "never ending story" πŸ”
  • PLAYMODE_FORWARD β€” plays the sample from beginning to end. this is the default if you don't set the backward flag. forward momentum, we love to see it ⭐
  • PLAYMODE_BACKWARD β€” reverses the direction of the sample. and if you combine this with the loop flag, the sample jumps to the loop end position upon reaching the loop start (ie. you do not need to reverse the loop start and end values when you play the sample in reverse β€” the function handles that for you, periodt). going backwards but make it ✨intentional✨
  • PLAYMODE_BIDIR β€” when used in combination with the loop flag, this causes the sample to change direction each time it reaches one of the loop points, so it alternates between playing forwards and in reverse. back and forth, back and forth, it's literally ping-pong but make it audio πŸ“πŸŒˆ
heads up bestie: these are bitfield values, so they're designed to be combined. PLAYMODE_BIDIR and PLAYMODE_BACKWARD's loop behaviour literally only kick in when you pair them with PLAYMODE_LOOP. read the flags, respect the flags. πŸ’œ

πŸ’œ SEE ALSO πŸ’œ

nothing else listed here β€” this page is a standalone icon, iykyk πŸ’…


k that's the whole page, bestie! this was from the Allegro manual, version 4.4.3, and the page is voice_set_playmode(3). go make something that loops beautifully πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from