DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::PhaseCorrelation< T > Class Template Reference

Correlation/balance meter and goniometer data source. More...

#include <PhaseCorrelation.h>

Classes

struct  GonioPoint
 One mid/side point for goniometer displays. More...
 

Public Member Functions

void prepare (const AudioSpec &spec, double windowMs=300.0) noexcept
 Prepares the meter. Allocation-free.
 
void reset () noexcept
 Clears the averages, the readouts and the goniometer ring.
 
void processBlock (AudioBufferView< const T > buffer) noexcept
 Analyzes a block (read-only; the audio is not modified).
 
getCorrelation () const noexcept
 
getBalance () const noexcept
 
int getGonioPoints (GonioPoint *dest, int maxCount) const noexcept
 Copies the newest goniometer points (oldest first).
 
double getWindowMs () const noexcept
 

Static Public Attributes

static constexpr int kGonioSize = 1024
 Goniometer ring length.
 

Detailed Description

template<FloatType T>
class dspark::PhaseCorrelation< T >

Correlation/balance meter and goniometer data source.

Template Parameters
TSample type (float or double).

Definition at line 66 of file PhaseCorrelation.h.

Member Function Documentation

◆ getBalance()

template<FloatType T>
T dspark::PhaseCorrelation< T >::getBalance ( ) const
inlinenoexcept
Returns
Energy balance in [-1, +1]; -1 = all left, +1 = all right.

Definition at line 210 of file PhaseCorrelation.h.

◆ getCorrelation()

template<FloatType T>
T dspark::PhaseCorrelation< T >::getCorrelation ( ) const
inlinenoexcept
Returns
Correlation in [-1, +1]; +1 in phase, -1 phase-inverted.

Definition at line 204 of file PhaseCorrelation.h.

◆ getGonioPoints()

template<FloatType T>
int dspark::PhaseCorrelation< T >::getGonioPoints ( GonioPoint dest,
int  maxCount 
) const
inlinenoexcept

Copies the newest goniometer points (oldest first).

Parameters
destDestination array (null is tolerated: returns 0).
maxCountCapacity of dest (clamped to kGonioSize).
Returns
Number of points copied.

Definition at line 221 of file PhaseCorrelation.h.

◆ getWindowMs()

template<FloatType T>
double dspark::PhaseCorrelation< T >::getWindowMs ( ) const
inlinenoexcept
Returns
Averaging time constant in ms from the last successful prepare().

Definition at line 235 of file PhaseCorrelation.h.

◆ prepare()

template<FloatType T>
void dspark::PhaseCorrelation< T >::prepare ( const AudioSpec spec,
double  windowMs = 300.0 
)
inlinenoexcept

Prepares the meter. Allocation-free.

Parameters
specAudio environment specification. An invalid or non-finite specification is ignored (conservative no-op: the previous state is kept).
windowMsAveraging time constant for the correlation (one-pole tau, default 300 ms). Clamped to [1, 600000]; a non-finite value falls back to the default.

Definition at line 89 of file PhaseCorrelation.h.

◆ processBlock()

template<FloatType T>
void dspark::PhaseCorrelation< T >::processBlock ( AudioBufferView< const T >  buffer)
inlinenoexcept

Analyzes a block (read-only; the audio is not modified).

Single-channel buffers measure as dual mono: r = +1 while signal is present (below the silence floor the readouts rest at 0, same as stereo), balance 0, and the goniometer collapses onto the mid axis.

Definition at line 129 of file PhaseCorrelation.h.

◆ reset()

template<FloatType T>
void dspark::PhaseCorrelation< T >::reset ( )
inlinenoexcept

Clears the averages, the readouts and the goniometer ring.

Allocation-free, but it writes the same plain accumulators processBlock() owns: call it from the stream owner (or with the stream stopped).

Definition at line 109 of file PhaseCorrelation.h.

Member Data Documentation

◆ kGonioSize

template<FloatType T>
constexpr int dspark::PhaseCorrelation< T >::kGonioSize = 1024
staticconstexpr

Goniometer ring length.

Definition at line 76 of file PhaseCorrelation.h.


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