Retrieves the level of a sample, stream, MOD music, or recording channel.

BOOL BASS_ChannelGetLevelEx(
    DWORD handle,
    float *levels,
    float length,
    DWORD flags


handleThe channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD.
levelsAn array to receive the levels.
lengthThe 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 channel's playback buffer is shorter.
flagsA combination of these flags.
BASS_LEVEL_MONOGet a mono level. If neither this or the BASS_LEVEL_STEREO flag is used, then a separate level is retrieved for each channel.
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_RMSGet the RMS level. Otherwise the peak level.

Return value

If successful, TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not a valid channel.
BASS_ERROR_ILLPARAMlength is not valid.
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.


This function operates in the same way as BASS_ChannelGetLevel but has greater flexibility on how the level is measured. The levels are not clipped, so may exceed +/-1.0 on floating-point channels.


Replicate BASS_ChannelGetLevel but with floating-point levels.
float levels[2];
BASS_ChannelGetLevelEx(handle, levels, 0.02, BASS_LEVEL_STEREO);

Get a mono RMS level reading in decibels using 50ms of data.

float level;
BASS_ChannelGetLevelEx(handle, &level;, 0.05, BASS_LEVEL_MONO|BASS_LEVEL_RMS); // get the level
float dblevel=(level>0?20*log10(level):-1000); // translate it to dB

Get a peak level reading for each channel using 20ms of data.

BASS_ChannelGetInfo(handle, &ci;);
float *levels=(float*)malloc(ci.chans*sizeof(float)); // allocate an array for each channel's level
BASS_ChannelGetLevelEx(handle, levels, 0.02, 0); // get the levels

See also

BASS_ChannelGetData, BASS_ChannelGetLevel, BASS_ChannelIsActive