Gin
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
LoudnessMeter Class Reference

Loudness meter per ITU-R BS.1770-4 / EBU R128. More...

#include <gin_loudnessmeter.h>

Public Member Functions

 LoudnessMeter ()=default
 
void prepare (double sampleRate, int numChannels, double maxHistorySeconds=24.0 *60.0 *60.0)
 maxHistorySeconds bounds the memory used for the integrated / range histories (about 40 kB per hour).
 
void reset ()
 Clears everything, including the integrated history.
 
void process (const juce::AudioBuffer< float > &buffer)
 Audio thread.
 
float getMomentary () const
 
float getShortTerm () const
 
float getMaxMomentary () const
 
float getMaxShortTerm () const
 
float getIntegrated () const
 Gated integrated loudness since the last reset.
 
float getLoudnessRange () const
 Loudness range (EBU Tech 3342) since the last reset, in LU.
 
double getElapsedSeconds () const
 Seconds of audio measured since the last reset.
 
void setChannelWeight (int channel, float weight)
 

Static Public Member Functions

static float powerToLoudness (double power)
 Converts a mean square power to loudness.
 
static double loudnessToPower (float loudness)
 

Static Public Attributes

static constexpr float silence = -100.0f
 

Detailed Description

Loudness meter per ITU-R BS.1770-4 / EBU R128.

Call process() from the audio thread. The momentary (400 ms) and short-term (3 s) values are updated every 100 ms and can be read from any thread. Integrated loudness and loudness range are gated measurements over the whole history since the last reset; they are computed on demand from that history by getIntegrated() / getLoudnessRange(), which are intended to be called from the message thread as they do a little work.

Channel weighting follows the standard: 1.0 for the first three channels (L, R, C) and 1.41 for channels 4 and 5 (Ls, Rs).

Values are in LUFS (LU for the range). Below the measurable floor, or before any audio has been processed, getters return silence.

Constructor & Destructor Documentation

◆ LoudnessMeter()

LoudnessMeter::LoudnessMeter ( )
default

Member Function Documentation

◆ prepare()

void LoudnessMeter::prepare ( double  sampleRate,
int  numChannels,
double  maxHistorySeconds = 24.0 *60.0 *60.0 
)

maxHistorySeconds bounds the memory used for the integrated / range histories (about 40 kB per hour).

Not realtime safe.

◆ reset()

void LoudnessMeter::reset ( )

Clears everything, including the integrated history.

Safe to call from any thread; takes effect on the next process() call.

◆ process()

void LoudnessMeter::process ( const juce::AudioBuffer< float > &  buffer)

Audio thread.

Uses up to the prepared number of channels.

◆ getMomentary()

float LoudnessMeter::getMomentary ( ) const

◆ getShortTerm()

float LoudnessMeter::getShortTerm ( ) const

◆ getMaxMomentary()

float LoudnessMeter::getMaxMomentary ( ) const

◆ getMaxShortTerm()

float LoudnessMeter::getMaxShortTerm ( ) const

◆ getIntegrated()

float LoudnessMeter::getIntegrated ( ) const

Gated integrated loudness since the last reset.

Message thread.

◆ getLoudnessRange()

float LoudnessMeter::getLoudnessRange ( ) const

Loudness range (EBU Tech 3342) since the last reset, in LU.

Message thread.

◆ getElapsedSeconds()

double LoudnessMeter::getElapsedSeconds ( ) const

Seconds of audio measured since the last reset.

◆ setChannelWeight()

void LoudnessMeter::setChannelWeight ( int  channel,
float  weight 
)

◆ powerToLoudness()

static float LoudnessMeter::powerToLoudness ( double  power)
static

Converts a mean square power to loudness.

◆ loudnessToPower()

static double LoudnessMeter::loudnessToPower ( float  loudness)
static

Member Data Documentation

◆ silence

constexpr float LoudnessMeter::silence = -100.0f
staticconstexpr

The documentation for this class was generated from the following file: