TracktionEngine
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
engine::StereoFieldAnalyser Class Reference

A real-time-safe stereo field analyser: phase correlation, stereo balance and stereo width, over a short sliding window and over the whole measurement. More...

#include <tracktion_StereoFieldAnalyser.h>

Classes

struct  Readings
 A snapshot of the analyser's current readings. More...
 

Public Member Functions

 StereoFieldAnalyser ()=default
 
void prepare (double sampleRate, int numChannels, int maxBlockSize)
 Allocates for the given format and resets the measurement.
 
void process (choc::buffer::ChannelArrayView< const float > block) noexcept
 Processes a block of audio, updating the published readings.
 
void process (const float *const *channels, int numChannels, int numSamples) noexcept
 Processes a block of audio from raw channel pointers.
 
void flush () noexcept
 For offline use: finishes a partially-filled analysis block if it's at least half full, so a file's tail contributes to the measurement.
 
void requestReset () noexcept
 Asks for the measurement, window history and held extremes to be restarted.
 
Readings getReadings () const noexcept
 Returns the current readings.
 

Detailed Description

A real-time-safe stereo field analyser: phase correlation, stereo balance and stereo width, over a short sliding window and over the whole measurement.

Everything is derived from running sums of l*l, r*r and l*r, updated on the same 100ms block cadence as LoudnessMeter's gating blocks with a 400ms sliding window for the "current" readings. For buffers with more than two channels, the first pair is measured (standard correlation-meter practice); for mono, the single channel is treated as both sides, so the readings describe a perfectly centred signal.

Real-time contract (identical to LoudnessMeter):

Constructor & Destructor Documentation

◆ StereoFieldAnalyser()

engine::StereoFieldAnalyser::StereoFieldAnalyser ( )
default

Member Function Documentation

◆ prepare()

void engine::StereoFieldAnalyser::prepare ( double  sampleRate,
int  numChannels,
int  maxBlockSize 
)

Allocates for the given format and resets the measurement.

Must be called before process(), and never whilst processing. Only the first two channels are analysed, but it's fine to prepare and feed wider buffers.

Parameters
maxBlockSizeaccepted for signature parity with LoudnessMeter::prepare - the analyser has no per-block working buffers, so any block length may be passed to process()

◆ process() [1/2]

void engine::StereoFieldAnalyser::process ( choc::buffer::ChannelArrayView< const float >  block)
noexcept

Processes a block of audio, updating the published readings.

Real-time safe: no allocation, no locks. The block can be any length.

See also
LoudnessMeter::process

◆ process() [2/2]

void engine::StereoFieldAnalyser::process ( const float *const *  channels,
int  numChannels,
int  numSamples 
)
noexcept

Processes a block of audio from raw channel pointers.

See also
process (choc::buffer::ChannelArrayView<const float>)

◆ flush()

void engine::StereoFieldAnalyser::flush ( )
noexcept

For offline use: finishes a partially-filled analysis block if it's at least half full, so a file's tail contributes to the measurement.

Call this after the last process() call, not during streaming.

◆ requestReset()

void engine::StereoFieldAnalyser::requestReset ( )
noexcept

Asks for the measurement, window history and held extremes to be restarted.

Picked up by the processing thread at the start of its next block, so this never blocks.

◆ getReadings()

Readings engine::StereoFieldAnalyser::getReadings ( ) const
noexcept

Returns the current readings.

Lock-free, callable from any thread.


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