BASS.NET API for the Un4seen BASS Audio LibraryBassMix BASS_Mixer_ChannelGetLevel Method (Int32,  Single )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: 2.4.11.0
Syntax

public static bool BASS_Mixer_ChannelGetLevel(
	int handle,
	float[] level
)

Parameters

handle
Type: OnlineSystem Int32
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).
level
Type:  OnlineSystem Single 
The array which will receive the peak levels values. The size of the array must be set to the number of channels of the stream (e.g. 2 for stereo).

Return Value

On success   is returned - else  , use BASS_ErrorGetCode  to get the error code.

If successful, the peak levels of the interleaved channel order is returned in the level array. The level value ranges linearly from 0.0 (silent) to 1.0 (=0dB) or above.

Remarks

This function is like the 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_BUFFER flag.

If the mixer is a decoding channel, then the channel's most recent data will be used to get the level. Otherwise, the level will be in sync with what is currently being heard from the mixer, unless the buffer is too small so that the currently heard data isn't in it. The BASS_CONFIG_MIXER_BUFFER config option can be used to set the buffer size.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not a valid channel.
BASS_DATA_AVAILABLEQuery the amount of data the channel has buffered. This flag is primarily of use when recording, and can't be used with decoding channels as they do not have playback buffers. buffer can be   when using this flag.

Examples

Get the left and right levels of a stereo channel:
float[] level = new float[2]; // dealing with stereo 
if (BassMix.BASS_Mixer_ChannelGetLevel(channel, level))
{
  float left  = level[0]; // the left level 
  float right = level[1]; // the right level
}
See Also