Gated, octave-safe, semitone-smoothed pitch tracking source.
More...
#include <PitchFollower.h>
|
| void | prepare (const AudioSpec &spec, int windowSize=0) |
| | 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.
|
| |
| T | getMinHz () const noexcept |
| | Returns the lower bound of the accepted pitch range in Hz.
|
| |
| T | getMaxHz () const noexcept |
| | Returns the upper bound of the accepted pitch range in Hz.
|
| |
| T | getConfidenceThreshold () const noexcept |
| | Returns the confidence gating threshold [0, 1].
|
| |
| T | getGlide () const noexcept |
| | Returns the glide time in milliseconds per octave.
|
| |
| int | getWindowSize () const noexcept |
| |
| T | getSmoothedHz () const noexcept |
| |
| T | getRawHz () const noexcept |
| |
| T | 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).
|
| |
template<FloatType T>
class dspark::PitchFollower< T >
Gated, octave-safe, semitone-smoothed pitch tracking source.
- Template Parameters
-
| T | Sample type (float or double). |
Definition at line 75 of file PitchFollower.h.
◆ getConfidence()
- Returns
- Detector confidence of the last raw reading [0, 1].
Definition at line 195 of file PitchFollower.h.
◆ getConfidenceThreshold()
Returns the confidence gating threshold [0, 1].
Definition at line 172 of file PitchFollower.h.
◆ getGlide()
Returns the glide time in milliseconds per octave.
Definition at line 175 of file PitchFollower.h.
◆ getMaxHz()
Returns the upper bound of the accepted pitch range in Hz.
Definition at line 169 of file PitchFollower.h.
◆ getMinHz()
Returns the lower bound of the accepted pitch range in Hz.
Definition at line 166 of file PitchFollower.h.
◆ getRawHz()
- Returns
- Last raw detector reading in Hz (ungated - may be garbage).
Definition at line 192 of file PitchFollower.h.
◆ getSmoothedHz()
- Returns
- Smoothed pitch in Hz; 0 until the first reliable reading.
Definition at line 186 of file PitchFollower.h.
◆ getWindowSize()
- Returns
- The wrapped detector's analysis window in samples (the automatic choice unless prepare() was given an explicit one). The lowest trackable fundamental is sampleRate/(getWindowSize()/2 - 1).
Definition at line 181 of file PitchFollower.h.
◆ isTracking()
- Returns
- True while reliable readings arrived within the last 250 ms.
Definition at line 198 of file PitchFollower.h.
◆ prepare()
Prepares the follower and the wrapped detector.
An invalid spec (non-finite or non-positive fields) is ignored, keeping the previous state.
- Parameters
-
| spec | Audio environment specification. |
| windowSize | Detector analysis window. Values <= 0 (the default) select PitchDetector's AUTOMATIC window: 2048 at 44.1/48 kHz, 4096 at 88.2/96 kHz, 8192 at 176.4/192 kHz. Explicit positive values are forwarded as given (with a hop of windowSize/4). |
The tracked register is the detector's: the lowest reachable fundamental is sampleRate/(windowSize/2 - 1), so it depends on the RATIO, never on the count. The automatic window is good down to ~47 Hz at every rate from 44.1 to 192 kHz. A fixed 2048-sample window would instead stop at ~94 Hz at 96 kHz and ~188 Hz at 192 kHz: measured, a 55 Hz or 82 Hz sawtooth then never leaves getSmoothedHz() at 0 and isTracking() stays false, whatever setRange() says – the range gate cannot widen a register the detector cannot reach. For a lower floor pass an explicit window (doubling it halves the floor and doubles the analysis latency).
Definition at line 103 of file PitchFollower.h.
◆ processBlock()
Feeds a block (any channel count); channels are averaged to mono.
- Parameters
-
| buffer | Read-only audio block. |
Definition at line 209 of file PitchFollower.h.
◆ pushSamples()
Feeds mono samples directly (alternative to processBlock).
- Parameters
-
Definition at line 245 of file PitchFollower.h.
◆ reset()
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 119 of file PitchFollower.h.
◆ setConfidence()
Confidence threshold [0, 1] below which readings are ignored (default 0.85).
Definition at line 148 of file PitchFollower.h.
◆ setGlide()
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 159 of file PitchFollower.h.
◆ setRange()
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 138 of file PitchFollower.h.
The documentation for this class was generated from the following file: