pub struct PitchTracker { /* private fields */ }Expand description
Per-stream pitch-tracker state, matching OP25’s pitch_est member
variables. All fields are prefixed prev by design — they’re the
rolling history the look-back / cumulative-error tests consume.
Implementations§
Source§impl PitchTracker
impl PitchTracker
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Fresh tracker. Initializes to OP25’s canonical defaults:
prev_pitch_idx = 116 (period ≈ 79 samples), prev_e_p = 0.
Sourcepub fn estimate(&mut self, pitch_est_buf: &[f32; 301]) -> PitchEstimate
pub fn estimate(&mut self, pitch_est_buf: &[f32; 301]) -> PitchEstimate
Estimate pitch from a pitch-history buffer via IMBE e_p +
look-back tracking only.
pitch_est_buf is the 301-sample LPF’d buffer. See
compute_e_p for the E(p) derivation. This single-frame
entry point is zero-latency; for the full OP25 look-ahead DP
use Self::estimate_with_lookahead.
§Algorithm (single-frame path)
compute_e_pthe 203-entryE(p)array for this frame.- Look-back search: pick the
E(p)minimum insideMIN_MAX_TBL[prev_pitch_idx]. IfE + prev_E + prev_prev_E ≤ 0.48, commit it. - Otherwise fall back to the global
E(p)minimum. - Sub-multiples analysis tests
p/2..p/5per OP25’s 3-tier threshold cascade; the winner is committed.
Source§impl PitchTracker
impl PitchTracker
Sourcepub fn estimate_with_lookahead(
&mut self,
e_p_current: &[f32; 203],
e_p_next: &[f32; 203],
e_p_nextnext: &[f32; 203],
) -> PitchEstimate
pub fn estimate_with_lookahead( &mut self, e_p_current: &[f32; 203], e_p_next: &[f32; 203], e_p_nextnext: &[f32; 203], ) -> PitchEstimate
Run OP25’s full pitch tracker: single-frame look-back, fall
through to 2-frame-look-ahead DP on pitch_est.cc:229–270,
then sub-multiples analysis, then pick look-back vs
look-ahead by comparing cumulative-error scores.
e_p_current is the E(p) array for the frame being
committed; e_p_next is the array for the frame that will
be committed next, and e_p_nextnext the one after that.
Callers are expected to buffer 2 frames of future
compute_e_p output before invoking this method; the
encoder’s 40 ms effective latency is the cost.
State is advanced exactly as in the single-frame path
— prev_pitch_idx, prev_e_p, and their prev_prev
shadows roll forward.
Trait Implementations§
Source§impl Clone for PitchTracker
impl Clone for PitchTracker
Source§fn clone(&self) -> PitchTracker
fn clone(&self) -> PitchTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more