BASS_ASIO_ChannelGetLevel

Retrieves the level of a channel.

float BASS_ASIO_ChannelGetLevel(
    BOOL input,
    DWORD channel
);

Parameters

inputDealing with an input channel? FALSE = an output channel.
channelThe input/output channel number... 0 = first. The BASS_ASIO_LEVEL_RMS flag can optionally be used to get the RMS level, otherwise the peak level is given.

Return value

If an error occurs, -1 is returned, use BASS_ASIO_ErrorGetCode to get the error code. If successful, the level of the channel is returned, ranging from 0 (silent) to 1 (max). If the channel's native sample format is floating-point, it is actually possible for the level to go above 1.

Error codes

BASS_ERROR_INITBASS_ASIO_Init has not been successfully called.
BASS_ERROR_ILLPARAMThe input and channel combination is invalid.
BASS_ERROR_STARTThe device has not been started, or the channel is not enabled.
BASS_ERROR_FORMATLevel retrieval is not supported for the channel's sample format.

Remarks

This function measures the current level of a single channel, and is not affected by any other channels that are joined with it. The level reading is taken from the channel's most recent buffer, so the amount of data looked at to get the level reading is determined by the buffer length set with BASS_ASIO_Start.

Volume settings made via BASS_ASIO_ChannelSetVolume affect the level reading of output channels, but not input channels.

When an input channel is paused, it is still possible to get its current level. Paused output channels will have a level of 0.

Level retrieval is not supported when the sample format is DSD.

Example

Get the peak level of the first output channel in decibels.
float level = BASS_ASIO_ChannelGetLevel(FALSE, 0); // get the linear level
float dblevel = (level > 0 ? 20 * log10(level) : -HUGE_VAL); // translate it to dB

Get the RMS level of the first output channel in decibels.

float level = BASS_ASIO_ChannelGetLevel(FALSE, 0 | BASS_ASIO_LEVEL_RMS); // get the linear RMS level
float dblevel = (level > 0 ? 20 * log10(level) : -HUGE_VAL); // translate it to dB

See also

BASS_ASIO_ChannelGetVolume, BASS_ASIO_ChannelIsActive, BASS_ASIO_ChannelSetVolume