BASS_Loudness_GetLevel

Retrieves the level of a loudness measurement.

BOOL BASS_Loudness_GetLevel(
    HLOUDNESS handle,
    DWORD mode,
    float *level
);

Parameters

handleThe loudness measurement handle.
modeThe measurement type to retrieve. One of the following.
BASS_LOUDNESS_CURRENTLoudness in LUFS of the last 400ms or the duration (in milliseconds) specified in the HIWORD; use MAKELONG(mode,duration).
BASS_LOUDNESS_INTEGRATEDIntegrated loudness in LUFS. This is the average since measurement started.
BASS_LOUDNESS_RANGELoudness range in LU.
BASS_LOUDNESS_PEAKPeak level in linear scale.
BASS_LOUDNESS_TRUEPEAKTrue peak level in linear scale.
levelPointer to a variable to receive the measurement level.

Return value

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

Remarks

Loudness is measured according to the ITU-R BS.1770-4 standard (LUFS = LKFS). The BASS_LOUDNESS_INTEGRATED measurement is gated so that much quieter periods are excluded and do not bring down the measured level, while the other measurements are not gated. Loudness (not peak) levels will be -infinity in the case of pure silence, or if the minimum amount of data has not been processed yet. The BASS_LOUDNESS_INTEGRATED measurement requires at least 400ms of data and is updated every 100ms after that. The BASS_LOUDNESS_RANGE measurement requires at least 4s of data and is updated every 1s after that. The other measurements are updated with every sample, but the BASS_LOUDNESS_CURRENT levels may be lower than expected before the requested duration has been processed.

The BASS_LOUDNESS_CURRENT mode can be used with durations of 400ms and 3000ms to get EBU R128 "momentary" and "short-term" loudness levels, respectively. The other modes are equivalent to the EBU R128 measurements of the same name.

Error codes

BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_ILLPARAMmode is not valid. If requesting a duration with BASS_LOUDNESS_CURRENT then it exceeds what has been enabled.
BASS_ERROR_NOTAVAILThe requested measurement has not been enabled.

Example

Get the loudness level of the last 1 second.
float level;
BASS_Loudness_GetLevel(handle, MAKELONG(BASS_LOUDNESS_CURRENT, 1000), &level);

Get the true peak level in decibels.

float level;
BASS_Loudness_GetLevel(handle, BASS_LOUDNESS_TRUEPEAK, &level); // get true peak level
float dblevel = log10(level) * 20; // translate it to dB

See also

BASS_Loudness_GetLevelMulti, BASS_Loudness_Start