PitchTracker

Struct PitchTracker 

Source
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

Source

pub const fn new() -> Self

Fresh tracker. Initializes to OP25’s canonical defaults: prev_pitch_idx = 116 (period ≈ 79 samples), prev_e_p = 0.

Source

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)
  1. compute_e_p the 203-entry E(p) array for this frame.
  2. Look-back search: pick the E(p) minimum inside MIN_MAX_TBL[prev_pitch_idx]. If E + prev_E + prev_prev_E ≤ 0.48, commit it.
  3. Otherwise fall back to the global E(p) minimum.
  4. Sub-multiples analysis tests p/2..p/5 per OP25’s 3-tier threshold cascade; the winner is committed.
Source§

impl PitchTracker

Source

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

Source§

fn clone(&self) -> PitchTracker

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PitchTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PitchTracker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for PitchTracker

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.