Retrieves the level of a sample, stream, MOD music, or recording channel.
BOOL BASS_ChannelGetLevelEx( DWORD handle, float *levels, float length, DWORD flags );
|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, except for decoding channels. 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.|
|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.|
When the BASS_LEVEL_NOREMOVE flag is used to prevent the inspected data being removed from a recording channel's buffer, any DSP/FX set on it will not be present in the level reading, as they are only applied when the data leaves the recording buffer.
float levels; 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