PYINExecutor

Struct PYINExecutor 

Source
pub struct PYINExecutor<A>{ /* private fields */ }
Expand description

pYIN algorithm executor.

It’s generic over the input type, which can bef32 or f64. It contains memory for the FFTs and some reusable constants. The new() method creates a new instance, and the pyin() method executes the algorithm.

Implementations§

Source§

impl<A> PYINExecutor<A>

Source

pub fn set_boltzmann_parameter(&mut self, val: f64) -> &mut Self

shape parameter for the Boltzmann distribution prior over troughs. Larger values will assign more mass to smaller periods. (default: 2.0)

Source

pub fn set_no_trough_prob(&mut self, val: A) -> &mut Self

maximum probability to add to global minimum if no trough is below threshold. (default: 0.01)

Source§

impl<A> PYINExecutor<A>

Source

pub fn n_thresholds(&self) -> usize

number of thresholds for peak estimation. (always returns 100)

Source

pub fn beta_parameters(&self) -> (f64, f64)

shape parameters for the beta distribution prior over thresholds. (always returns (2.0, 18.0))

Source

pub fn boltzmann_parameter(&self) -> f64

shape parameter for the Boltzmann distribution prior over troughs. Larger values will assign more mass to smaller periods. (default: 2.0)

Source

pub fn max_transition_rate(&self) -> f64

maximum pitch transition rate in octaves per second. (always returns 35.92)

Source

pub fn switch_prob(&self) -> A

probability of switching from voiced to unvoiced or vice versa. (always returns 0.01)

Source

pub fn no_trough_prob(&self) -> A

maximum probability to add to global minimum if no trough is below threshold. (default: 0.01)

Source§

impl<A> PYINExecutor<A>

Source

pub fn new( fmin: f64, fmax: f64, sr: u32, frame_length: usize, win_length: Option<usize>, hop_length: Option<usize>, resolution: Option<f64>, ) -> Self

Create a new PYIN executor instance.

§Arguments
  • fmin - minimum frequency in Hz
  • fmax - maximum frequency in Hz
  • sr - sampling rate in Hz
  • frame_length - frame length in samples
  • win_length - length of the window for calculating autocorrelation in samples. (If None, defaults to frame_length/2)
  • hop_length - number of audio samples between adjacent pYIN predictions. (If None, defaults to frame_length/4)
  • resolution - Resolution of the pitch bins. should be 0 < resolution < 1. 0.01 corresponds to cents.(If None, defaults to 0.1)
Source

pub fn pyin( &mut self, wav: &[A], fill_unvoiced: A, framing: Framing<A>, ) -> (Vec<f64>, Vec<A>, Vec<bool>, Vec<A>)

Execute pYIN algorithm.

§Arguments
  • wav - audio signal
  • fill_unvoiced - value to fill unvoiced frames. Typically, it is 0.0 or <A as Float>::nan().
  • framing - where the first frame starts. Refer to Framing
§Returns

(timestamp: Array1<f64>, f0: Array1<A>, voiced_flag: Array1<bool>, voiced_prob: Array1<A>)

  • timestamp - contains the timestamp (in seconds) of each frames
  • f0 - contains estimated pitch in Hz. (If unvoiced, it is fill_unvoiced.)
  • voiced_flag - contains whether each frame is voiced or unvoiced.
  • voiced_prob - contains probability of each frame being voiced.
Source

pub fn frame_to_sec(&self, i_frame: usize) -> f64

Trait Implementations§

Source§

impl<A> Clone for PYINExecutor<A>

Source§

fn clone(&self) -> PYINExecutor<A>

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

Auto Trait Implementations§

§

impl<A> Freeze for PYINExecutor<A>
where A: Freeze,

§

impl<A> !RefUnwindSafe for PYINExecutor<A>

§

impl<A> Send for PYINExecutor<A>

§

impl<A> Sync for PYINExecutor<A>

§

impl<A> Unpin for PYINExecutor<A>
where A: Unpin,

§

impl<A> !UnwindSafe for PYINExecutor<A>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V