BASS.NET API for the Un4seen BASS Audio Library

BassMixBASS_Mixer_ChannelGetLevel Method (Int32, Single, BASSLevel)

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.17.5
Syntax

public static float[] BASS_Mixer_ChannelGetLevel(
	int handle,
	float length = 0,02f,
	BASSLevel flags = BASSLevel.BASS_LEVEL_ALL
)

Parameters

handle
Type: SystemInt32
The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD.
length (Optional)
Type: SystemSingle
The amount of data to inspect to calculate the level, in seconds. The maximum is 1 second. Less data than requested may be used if the full amount is not available, eg. if the source's buffer (determined by the BASS_CONFIG_MIXER_BUFFER config option) is shorter.
flags (Optional)
Type: Un4seen.BassBASSLevel
What levels to retrieve. One of the following (see BASSLevel):
BASS_LEVEL_ALLRetrieves a separate level for each channel.
BASS_LEVEL_MONORetrieve a single mono level.
BASS_LEVEL_STEREOGet a stereo level. The left level will be from the even channels, and the right level will be from the odd channels. If there are an odd number of channels then the left and right levels will both include all channels.
BASS_LEVEL_RMSFlag: Get the RMS level. Otherwise the peak level.
BASS_LEVEL_VOLPANApply the current BASS_ATTRIB_VOL and BASS_ATTRIB_PAN values to the level reading.

Return Value

Type: Single
On success the array of levels is returned - else , use BASS_ErrorGetCode to get the error code.
Remarks

This function is like the standard BASS_Mixer_ChannelGetLevel(Int32), 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_CHAN_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(Int32, BASSMIXEnvelope, BASS_MIXER_NODE, Int32).

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.

See Also

Reference