DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
PhaseCorrelation.h File Reference

Stereo phase correlation meter with goniometer feed. More...

#include "../Core/AudioBuffer.h"
#include "../Core/AudioSpec.h"
#include "../Core/DspMath.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <bit>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <type_traits>
Include dependency graph for PhaseCorrelation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::PhaseCorrelation< T >
 Correlation/balance meter and goniometer data source. More...
 
struct  dspark::PhaseCorrelation< T >::GonioPoint
 One mid/side point for goniometer displays. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Stereo phase correlation meter with goniometer feed.

The standard broadcast correlation meter: the normalized cross-correlation of left and right at lag zero, exponentially windowed,

r = E[L*R] / sqrt(E[L^2] * E[R^2]) in [-1, +1]

+1 means mono-compatible (in phase), 0 uncorrelated (wide/reverberant), -1 out of phase (mono cancellation). A stereo balance readout and a decimated mid/side point ring for goniometer (vectorscope) displays are included.

Readout floor: with program below roughly -120 dBFS RMS both correlation and balance read 0 (silence has no meaningful phase relationship).

Non-finite input samples: the poisoned averaging window is discarded (the accumulators restart from zero) and the last published readings are held; measurement resumes on the next clean block. Non-finite samples never reach the goniometer ring.

Threading:

  • prepare(): setup thread (allocation-free; not concurrent with processing).
  • processBlock(): audio thread (single stream owner).
  • reset(): stream owner or setup (touches the same plain accumulators processBlock() writes; allocation-free).
  • getCorrelation() / getBalance() / getGonioPoints(): any thread, lock-free. Goniometer points are individually atomic, so a concurrent reader never observes torn values; a reader that overlaps a large writer block may briefly copy points newer than the published write index (valid mid/side data, display-only reordering).
  • getWindowMs(): reflects the last successful prepare(); read it from the setup thread or once preparation is complete.

Dependencies: AudioBuffer.h, AudioSpec.h, DspMath.h.

Definition in file PhaseCorrelation.h.