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

Stereo phase correlation and balance meter. More...

#include <gin_correlationmeter.h>

Public Member Functions

 CorrelationMeter ()=default
 
void prepare (double sampleRate, double windowSeconds=0.3)
 
void setWindow (double windowSeconds)
 Averaging time constant.
 
double getWindowSeconds () const
 
void reset ()
 Clears the averages.
 
void process (const float *left, const float *right, int numSamples)
 
void process (const juce::AudioBuffer< float > &buffer)
 Uses the first two channels.
 
float getCorrelation () const
 -1 to +1.
 
float getBalance () const
 -1 (left only) to +1 (right only).
 

Detailed Description

Stereo phase correlation and balance meter.

Correlation is the normalised cross-correlation of left and right at zero lag: +1 for identical channels (mono), 0 for unrelated signals, -1 for identical but inverted channels. Balance is derived from the RMS of each side: -1 is all left, +1 all right. Both are averaged with a one pole filter whose time constant is set by setWindow().

Call process() from the audio thread; the getters are safe from any thread.

Constructor & Destructor Documentation

◆ CorrelationMeter()

CorrelationMeter::CorrelationMeter ( )
default

Member Function Documentation

◆ prepare()

void CorrelationMeter::prepare ( double  sampleRate,
double  windowSeconds = 0.3 
)

◆ setWindow()

void CorrelationMeter::setWindow ( double  windowSeconds)

Averaging time constant.

Realtime safe.

◆ getWindowSeconds()

double CorrelationMeter::getWindowSeconds ( ) const

◆ reset()

void CorrelationMeter::reset ( )

Clears the averages.

Safe from any thread.

◆ process() [1/2]

void CorrelationMeter::process ( const float *  left,
const float *  right,
int  numSamples 
)

◆ process() [2/2]

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

Uses the first two channels.

A mono buffer reads as fully correlated.

◆ getCorrelation()

float CorrelationMeter::getCorrelation ( ) const

-1 to +1.

Returns 0 when both channels are silent.

◆ getBalance()

float CorrelationMeter::getBalance ( ) const

-1 (left only) to +1 (right only).

0 when balanced or silent.


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