Page 1 of 1

Playing sounds at specific channels

Posted: Sat Nov 22, 2025 1:59 pm
by Lebostein
The only way to use multiple channels for sound output is the flag #PB_Sound_MultiChannel. But this means that the channel is assigned automatically. You cannot control whether a sound can only be played once, for example. Or if a particular object or instrument (or a part of an instrument like a string) can only make one sound at a time, then you play all those sounds on one channel. That way, the sounds and their reverberations cannot overlap. I would like to request a manual channel selection, as with FMOD or BASS.

Since the flags #PB_Sound_Loop and #PB_Sound_MultiChannel already occupy the values 1 and 2, negative values would be an idea:

InitSound(32) ; channels 0 to 31 are reserved
PlaySound(#Sound1, -1) -> Use channel 1 to play #Sound1
PlaySound(#Sound2, -5) -> Use channel 5 to play #Sound2
PlaySound(#Sound3, -1) -> Use channel 1 again (and stop #Sound1 if it is still playing) and play #Sound3
channel = PlaySound(#Sound4, #PB_Sound_MultiChannel) -> Play Sound4 on a free channel, the selected channel is returned.