Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pitch_track.hpp
Go to the documentation of this file.
1#pragma once
2
56
57#include "audio_metrics.hpp" // kSilenceFloorDb, FrequencyEstimate
58#include "audio_spectrum.hpp" // Window, kDefaultKaiserBeta, fit_tone
59
60#include <pulp/audio/buffer.hpp>
61
62#include <span>
63#include <vector>
64
65namespace pulp::test::audio {
66
71double cents_between(double hz, double reference_hz);
72
76 double hz = 0.0;
80 double confidence = 0.0;
84 bool voiced = false;
88 double coarse_hz = 0.0;
90};
91
98 int fft_length = 16384;
102 double min_hz = 20.0;
103 double max_hz = 0.0;
112 double min_confidence = 0.5;
121 double silence_rms = 1.0e-4;
124 int channel = 0;
127};
128
137 double sample_rate,
138 const PitchOptions& options = {});
139
141PitchEstimate estimate_pitch(std::span<const float> samples, double sample_rate,
142 const PitchOptions& options = {});
143
146 double time_s = 0.0;
147 double hz = 0.0;
148 double confidence = 0.0;
149 bool voiced = false;
150};
151
156 int window_length = 8192;
159 int hop_length = 2048;
163 int channel = 0;
164};
165
169 double sample_rate = 0.0;
171 int hop_length = 0;
172 std::vector<PitchTrackPoint> points;
173
175 std::vector<double> voiced_times_s() const;
179 std::vector<double> voiced_hz() const;
180};
181
188PitchTrack track_pitch(std::span<const float> samples, double sample_rate,
189 const PitchTrackOptions& options = {});
190
191} // namespace pulp::test::audio
Deterministic offline signal metrics for rendered audio buffers.
Buffer-level offline spectrum analyzers: magnitude/frequency response and harmonic distortion (THD / ...
Non-owning view over multi-channel audio sample data.
Definition buffer.hpp:30
Definition additive_bank.hpp:218
Definition audio_artifacts.hpp:20
constexpr double kDefaultKaiserBeta
Default Kaiser β.
Definition audio_spectrum.hpp:151
PitchTrack track_pitch(std::span< const float > samples, double sample_rate, const PitchTrackOptions &options={})
Slide a window across samples, estimating the fundamental at each hop.
double cents_between(double hz, double reference_hz)
Musical interval between two frequencies in cents: 1200·log2(hz / reference).
PitchEstimate estimate_pitch(const pulp::audio::BufferView< const float > &signal, double sample_rate, const PitchOptions &options={})
Estimate the fundamental of one channel of an already-rendered buffer.
Window
Analysis window.
Definition audio_spectrum.hpp:91
@ blackman
Periodic Blackman.
Definition audio_spectrum.hpp:113
A single fundamental-frequency estimate.
Definition pitch_track.hpp:74
double hz
Estimated fundamental in Hz. 0.0 when voiced is false.
Definition pitch_track.hpp:76
double coarse_hz
Diagnostics — the coarse FFT-peak estimate before projection refinement, and the raw (unclamped) harm...
Definition pitch_track.hpp:88
double harmonic_energy_ratio
Definition pitch_track.hpp:89
double confidence
Fraction of the analyzed segment's energy explained by the fundamental and its harmonics,...
Definition pitch_track.hpp:80
bool voiced
False when the estimator refused: the segment was below the silence floor or its confidence fell unde...
Definition pitch_track.hpp:84
Options for estimate_pitch.
Definition pitch_track.hpp:93
double min_confidence
Voicing gate: confidence below this refuses the estimate.
Definition pitch_track.hpp:112
int analysis_offset
Definition pitch_track.hpp:125
double silence_rms
RMS below this (linear, ~−80 dBFS) is treated as silence and refused before any spectral work — a dea...
Definition pitch_track.hpp:121
double kaiser_beta
Definition pitch_track.hpp:109
int analysis_length
Definition pitch_track.hpp:126
double min_hz
Search band.
Definition pitch_track.hpp:102
double max_hz
Definition pitch_track.hpp:103
Window window
Window for the coarse peak.
Definition pitch_track.hpp:108
int harmonic_count
Harmonics (including the fundamental) summed for the confidence measure.
Definition pitch_track.hpp:118
int fft_length
FFT length for the coarse peak (power of two).
Definition pitch_track.hpp:98
int channel
Channel analyzed, and an offset/length window into it.
Definition pitch_track.hpp:124
Options for track_pitch.
Definition pitch_track.hpp:153
int window_length
Samples per analysis frame.
Definition pitch_track.hpp:156
PitchOptions pitch
Per-frame estimator options.
Definition pitch_track.hpp:162
int channel
Definition pitch_track.hpp:163
int hop_length
Samples between successive frame starts (the hop).
Definition pitch_track.hpp:159
One point on an f0(t) trajectory: the frame's center time and its estimate.
Definition pitch_track.hpp:145
bool voiced
False = this frame was refused.
Definition pitch_track.hpp:149
double time_s
Center of the analysis window, in seconds.
Definition pitch_track.hpp:146
double confidence
Per-frame confidence (see PitchEstimate).
Definition pitch_track.hpp:148
double hz
Fundamental (0 when unvoiced).
Definition pitch_track.hpp:147
An f0(t) trajectory extracted from a render — the demodulator output the drift/jitter statistics cons...
Definition pitch_track.hpp:168
std::vector< double > voiced_hz() const
Fundamentals of the voiced frames only, index-aligned to voiced_times_s().
std::vector< PitchTrackPoint > points
Definition pitch_track.hpp:172
std::vector< double > voiced_times_s() const
Center times of the voiced frames only, in order.
int hop_length
Definition pitch_track.hpp:171
double sample_rate
Definition pitch_track.hpp:169
int window_length
Definition pitch_track.hpp:170