BASS_ASIO_ChannelSetVolume

Sets a channel's volume.

BOOL BASS_ASIO_ChannelSetVolume(
    BOOL input,
    int channel,
    float volume
);

Parameters

inputDealing with an input channel? FALSE = an output channel.
channelThe input/output channel number... 0 = first, -1 = master.
volumeThe volume level... 0 (silent) - 1.0 (normal). Above 1.0 amplifies the sound.

Return value

If successful, then TRUE is returned, else FALSE is returned. Use BASS_ASIO_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_INITBASS_ASIO_Init has not been successfully called.
BASS_ERROR_ILLPARAMThe input and channel combination is invalid, or volume is below 0.

Remarks

Apart from the master volume (channel = -1), this function applies a volume level to a single channel, and does not affect any other channels that are joined with it. This allows balance control over joined channels by setting the individual volume levels accordingly. The final level of a channel is master volume x channel volume. The volume "curve" is linear, but logarithmic levels can be easily used (see the example below).

ASIO drivers do not provide volume control themselves, so the volume adjustments are applied to the sample data by BASSASIO. This also means that changes do not persist across sessions and the channel volume levels will always start at 1.0. Changes are ramped to prevent "click" sounds.

When the channel's sample format is DSD, a 0 volume setting will mute the channel and anything else will be treated as 1.0 (normal).

Example

Set a logarithmic volume level on output channel 0.
float volume = pow10(db / 20); // translate logarithmic dB level to linear
BASS_ASIO_ChannelSetVolume(FALSE, 0, volume); // apply it to output channel 0

See also

BASS_ASIO_ChannelGetVolume, BASS_ASIO_ChannelGetLevel