BASSmix

BASS_Mixer_ChannelGetLevel


Retrieves the level (peak amplitude) of a mixer source channel.

DWORD BASS_Mixer_ChannelGetLevel(
    DWORD handle
);

Parameters

handleThe channel handle.

Return value

If an error occurs, -1 is returned, use BASS_ErrorGetCode to get the error code. If successful, the level of the left channel is returned in the low word (low 16-bits), and the level of the right channel is returned in the high word (high 16-bits). If the channel is mono, then the low word is duplicated in the high word. The level ranges linearly from 0 (silent) to 32768 (max). 0 will be returned when a channel is stalled.

Error codes

BASS_ERROR_HANDLEhandle is not plugged into a mixer.
BASS_ERROR_NOTAVAILThe channel does not have buffering (BASS_MIXER_BUFFER) enabled.
BASS_ERROR_NOPLAYThe mixer is not playing.

Remarks

This function is like the standard BASS_ChannelGetLevel, but it gets the level from the channel's buffer instead of decoding data from the channel, which means that the mixer does not miss out on any data. In order to do this, the source channel must have buffering enabled via the BASS_MIXER_BUFFER flag.

This function measures the level of the channel's sample data, not its level in the mixer output. It includes the effect of any DSP/FX set on the channel, but not the effect of the channel's BASS_ATTRIB_VOL or BASS_ATTRIB_PAN attributes or matrix mixing or any envelope set via BASS_Mixer_ChannelSetEnvelope.

If the mixer is being played by BASS, the returned level will be in sync with what is currently being heard from the mixer. If another output system is being used, the BASS_ATTRIB_MIXER_LATENCY option can be used to tell the mixer what the latency is so that it can be taken account of, otherwise the channel's most recent data will be used to get the level. The BASS_CONFIG_MIXER_BUFFER config option determines how far back the level will be available from, so it should be set high enough to cover any latency.

More flexible level retrieval is available with BASS_Mixer_ChannelGetLevelEx.

See also

BASS_Mixer_ChannelGetData, BASS_Mixer_ChannelGetLevelEx, BASS_ATTRIB_MIXER_LATENCY, BASS_CONFIG_MIXER_BUFFER

BASS_ChannelGetLevel