BASS_ChannelGetLevelEx
Retrieves the level of a sample, stream, MOD music, or recording channel.
BOOL BASS_ChannelGetLevelEx( DWORD handle, float *levels, float length, DWORD flags );
Parameters
handle | The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. | ||||||
levels | An array to receive the levels. | ||||||
length | 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 channel's playback buffer is shorter. | ||||||
flags | A combination of these flags.
|
Return value
If successful, TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code.Error codes
BASS_ERROR_HANDLE | handle is not a valid channel. |
BASS_ERROR_ILLPARAM | length is not valid. |
BASS_ERROR_NOPLAY | The channel is not playing. |
BASS_ERROR_ENDED | The decoding channel has reached the end. |
BASS_ERROR_BUFLOST | Should not happen... check that a valid window handle was used with BASS_Init. |
Remarks
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.Example
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_CHANNELINFO ci; 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