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

Gated, octave-safe, semitone-smoothed pitch tracking source. More...

#include <PitchFollower.h>

Public Member Functions

void prepare (const AudioSpec &spec, int windowSize=2048)
 Prepares the follower and the wrapped detector.
 
void reset () noexcept
 Forgets the tracked pitch (parameters are kept). Allocation-free; call from the stream owner (it touches the same plain tracking state update() writes).
 
void setRange (T minHz, T maxHz) noexcept
 Accepted pitch range in Hz (default 60 to 1200). Non-finite values are ignored (the old max() passed NaN through and closed the validity gate forever).
 
void setConfidence (T threshold) noexcept
 Confidence threshold [0, 1] below which readings are ignored (default 0.85).
 
void setGlide (T msPerOctave) noexcept
 Glide time in milliseconds per octave (default 60). 0 disables smoothing (the output snaps to each accepted reading). Non-finite values are ignored.
 
getMinHz () const noexcept
 Returns the lower bound of the accepted pitch range in Hz.
 
getMaxHz () const noexcept
 Returns the upper bound of the accepted pitch range in Hz.
 
getConfidenceThreshold () const noexcept
 Returns the confidence gating threshold [0, 1].
 
getGlide () const noexcept
 Returns the glide time in milliseconds per octave.
 
getSmoothedHz () const noexcept
 
getRawHz () const noexcept
 
getConfidence () const noexcept
 
bool isTracking () const noexcept
 
void processBlock (AudioBufferView< const T > buffer) noexcept
 Feeds a block (any channel count); channels are averaged to mono.
 
void pushSamples (std::span< const T > samples) noexcept
 Feeds mono samples directly (alternative to processBlock).
 

Detailed Description

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

Gated, octave-safe, semitone-smoothed pitch tracking source.

Template Parameters
TSample type (float or double).

Definition at line 73 of file PitchFollower.h.

Member Function Documentation

◆ getConfidence()

template<FloatType T>
T dspark::PitchFollower< T >::getConfidence ( ) const
inlinenoexcept
Returns
Detector confidence of the last raw reading [0, 1].

Definition at line 173 of file PitchFollower.h.

◆ getConfidenceThreshold()

template<FloatType T>
T dspark::PitchFollower< T >::getConfidenceThreshold ( ) const
inlinenoexcept

Returns the confidence gating threshold [0, 1].

Definition at line 156 of file PitchFollower.h.

◆ getGlide()

template<FloatType T>
T dspark::PitchFollower< T >::getGlide ( ) const
inlinenoexcept

Returns the glide time in milliseconds per octave.

Definition at line 159 of file PitchFollower.h.

◆ getMaxHz()

template<FloatType T>
T dspark::PitchFollower< T >::getMaxHz ( ) const
inlinenoexcept

Returns the upper bound of the accepted pitch range in Hz.

Definition at line 153 of file PitchFollower.h.

◆ getMinHz()

template<FloatType T>
T dspark::PitchFollower< T >::getMinHz ( ) const
inlinenoexcept

Returns the lower bound of the accepted pitch range in Hz.

Definition at line 150 of file PitchFollower.h.

◆ getRawHz()

template<FloatType T>
T dspark::PitchFollower< T >::getRawHz ( ) const
inlinenoexcept
Returns
Last raw detector reading in Hz (ungated - may be garbage).

Definition at line 170 of file PitchFollower.h.

◆ getSmoothedHz()

template<FloatType T>
T dspark::PitchFollower< T >::getSmoothedHz ( ) const
inlinenoexcept
Returns
Smoothed pitch in Hz; 0 until the first reliable reading.

Definition at line 164 of file PitchFollower.h.

◆ isTracking()

template<FloatType T>
bool dspark::PitchFollower< T >::isTracking ( ) const
inlinenoexcept
Returns
True while reliable readings arrived within the last 250 ms.

Definition at line 176 of file PitchFollower.h.

◆ prepare()

template<FloatType T>
void dspark::PitchFollower< T >::prepare ( const AudioSpec spec,
int  windowSize = 2048 
)
inline

Prepares the follower and the wrapped detector.

An invalid spec (non-finite or non-positive fields) is ignored, keeping the previous state.

Parameters
specAudio environment specification.
windowSizeDetector analysis window (default 2048 - good down to ~50 Hz at 48 kHz; updates every windowSize/4 samples).

Definition at line 88 of file PitchFollower.h.

◆ processBlock()

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

Feeds a block (any channel count); channels are averaged to mono.

Parameters
bufferRead-only audio block.

Definition at line 187 of file PitchFollower.h.

◆ pushSamples()

template<FloatType T>
void dspark::PitchFollower< T >::pushSamples ( std::span< const T >  samples)
inlinenoexcept

Feeds mono samples directly (alternative to processBlock).

Parameters
samplesMono audio span.

Definition at line 223 of file PitchFollower.h.

◆ reset()

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

Forgets the tracked pitch (parameters are kept). Allocation-free; call from the stream owner (it touches the same plain tracking state update() writes).

Definition at line 103 of file PitchFollower.h.

◆ setConfidence()

template<FloatType T>
void dspark::PitchFollower< T >::setConfidence ( threshold)
inlinenoexcept

Confidence threshold [0, 1] below which readings are ignored (default 0.85).

Definition at line 132 of file PitchFollower.h.

◆ setGlide()

template<FloatType T>
void dspark::PitchFollower< T >::setGlide ( msPerOctave)
inlinenoexcept

Glide time in milliseconds per octave (default 60). 0 disables smoothing (the output snaps to each accepted reading). Non-finite values are ignored.

Definition at line 143 of file PitchFollower.h.

◆ setRange()

template<FloatType T>
void dspark::PitchFollower< T >::setRange ( minHz,
maxHz 
)
inlinenoexcept

Accepted pitch range in Hz (default 60 to 1200). Non-finite values are ignored (the old max() passed NaN through and closed the validity gate forever).

Definition at line 122 of file PitchFollower.h.


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