BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_ChannelGetLevel Method (Int32)BASS.NET API for the Un4seen BASS Audio Library
Retrieves the level (peak amplitude) of a sample, stream, MOD music or recording channel.

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

[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)]
public static int BASS_ChannelGetLevel(
	int handle


Type: SystemInt32
The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD.

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 measures the level of the channel's sample data, not the level of the channel in the final output mix, so the channel's volume and panning/balance (as set with BASS_ChannelSetAttribute(Int32, BASSAttribute, Single), BASS_ATTRIB_VOL or BASS_ATTRIB_PAN) does not affect it. The effect of any DSP/FX set on the channel is present in the measurement, except for DX8 effects when using the "With FX flag" DX8 effect implementation.

For channels that are more than stereo, the left level will include all left channels (eg. front-left, rear-left, center), and the right will include all right (front-right, rear-right, LFE). If there are an odd number of channels then the left and right levels will include all channels. If the level of each individual channel is required, that is available from the other overload(s).

20ms of data is inspected to calculate the level. When used with a decoding channel, that means 20ms of data needs to be decoded from the channel in order to calculate the level, and that data is then gone, eg. it is not available to a subsequent BASS_ChannelGetData(Int32, IntPtr, Int32) call.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not a valid channel.
BASS_ERROR_NOPLAYThe channel is not playing.
BASS_ERROR_ENDEDThe decoding channel has reached the end.
BASS_ERROR_BUFLOSTShould not happen... check that a valid window handle was used with BASS_Init(Int32, Int32, BASSInit, IntPtr, IntPtr).


Get the left and right levels of a stereo channel:
Dim level As Integer = Bass.BASS_ChannelGetLevel(channel)
Dim left As Integer = Utils.LowWord32(level) ' the left level
Dim right As Integer = Utils.HighWord32(level) ' the right level
int level = Bass.BASS_ChannelGetLevel(channel);
int left = Utils.LowWord32(level); // the left level
int right = Utils.HighWord32(level); // the right level
See Also