voice_set_playmode(3)
π 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_BIDIRandPLAYMODE_BACKWARD's loop behaviour literally only kick in when you pair them withPLAYMODE_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
- 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