Modifies and retrieves a channel's flags.

DWORD BASS_ChannelFlags(
    DWORD handle,
    DWORD flags,
    DWORD mask


handleThe channel handle... a HCHANNEL, HMUSIC, HSTREAM.
flagsA combination of these flags.
BASS_SAMPLE_LOOPLoop the channel.
BASS_STREAM_AUTOFREEAutomatically free the channel when playback ends. Note that the BASS_MUSIC_AUTOFREE flag is identical to this flag. (HSTREAM/HMUSIC only)
BASS_STREAM_RESTRATERestrict the download rate. (HSTREAM)
BASS_MUSIC_NONINTERUse non-interpolated sample mixing. (HMUSIC)
BASS_MUSIC_SINCINTERUse sinc interpolated sample mixing. (HMUSIC)
BASS_MUSIC_RAMPUse "normal" ramping. (HMUSIC)
BASS_MUSIC_RAMPSUse "sensitive" ramping. (HMUSIC)
BASS_MUSIC_SURROUND2Use surround sound mode 2. (HMUSIC)
BASS_MUSIC_FT2MODUse FastTracker 2 .MOD playback. (HMUSIC)
BASS_MUSIC_PT1MODUse ProTracker 1 .MOD playback. (HMUSIC)
BASS_MUSIC_POSRESETStop all notes when seeking. (HMUSIC)
BASS_MUSIC_POSRESETEXStop all notes and reset BPM/etc when seeking. (HMUSIC)
BASS_MUSIC_STOPBACKStop when a backward jump effect is played. (HMUSIC)
BASS_SPEAKER_xxxSpeaker assignment flags. (HSTREAM/HMUSIC)
other flags may be supported by add-ons, see the documentation.
maskThe flags (as above) to modify. Flags that are not included in this are left as they are, so it can be set to 0 in order to just retrieve the current flags. To modify the speaker flags, any of the BASS_SPEAKER_xxx flags can be used in the mask (no need to include all of them).

Return value

If successful, the channel's updated flags are returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not a valid channel.


Some flags may not be adjustable in some circumstances, so the return value should be checked to confirm any changes. The flags listed above are just the flags that can be modified, and there may be additional flags present in the return value. See the BASS_CHANNELINFO documentation for a full list of flags.

Streams that are created by add-ons may have additional flags available. There is a limited number of possible flag values though, so some add-ons may use the same flag value for different things. This means that when using add-on specific flags with a stream created via the plugin system, it is a good idea to first confirm that the add-on is handling the stream, by checking its ctype via BASS_ChannelGetInfo.

During playback, the effects of flag changes are not heard instantaneously, due to buffering. To reduce the delay, use the BASS_CONFIG_BUFFER config option to reduce the buffer length.


Toggle looping on a channel.
if (BASS_ChannelFlags(channel, 0, 0)&BASS_SAMPLE_LOOP) { // looping is enabled, so...
    BASS_ChannelFlags(channel, 0, BASS_SAMPLE_LOOP); // remove the LOOP flag
} else { // looping is disabled, so...
    BASS_ChannelFlags(channel, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set the LOOP flag

See also

BASS_ChannelGetAttribute, BASS_ChannelGetInfo, BASS_ChannelSetAttribute, BASS_MusicLoad