BASS.NET API for the Un4seen BASS Audio Library

BassMixBASS_Mixer_ChannelGetLevel Method (Int32)

BASS.NET API for the Un4seen BASS Audio Library
Retrieves the level (peak amplitude) of a mixer source channel.

Namespace:  Un4seen.Bass.AddOn.Mix
Assembly:  Bass.Net (in Bass.Net.dll) Version:

public static int BASS_Mixer_ChannelGetLevel(
	int handle


Type: SystemInt32
The handle of the mixer source channel (which was add via BASS_Mixer_StreamAddChannel(Int32, Int32, BASSFlag) or BASS_Mixer_StreamAddChannel(Int32, Int32, BASSFlag) or BASS_Mixer_StreamAddChannelEx(Int32, Int32, BASSFlag, Int64, Int64)) beforehand).

Return Value

Type: Int32
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, use LowWord32(Int32)), and the level of the right channel is returned in the high word (high 16-bits, use HighWord32(Int32)). 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.


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

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.

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


Get the left and right levels of a stereo channel:
BassMix.BASS_Mixer_StreamAddChannel(mixer, channel, BASSFlag.BASS_MIXER_CHAN_BUFFER);
int level = BassMix.BASS_Mixer_ChannelGetLevel(channel);
int left = Utils.LowWord32(level); // the left level
int right = Utils.HighWord32(level); // the right level
See Also