Skip to main content

Interpolator

Struct Interpolator 

Source
pub struct Interpolator { /* private fields */ }
Expand description

The band-limited interpolation a clip played at another speed reads its source through: the same Kaiser-windowed sinc as Resampler (16 taps a side at unity, cutoff 0.97 of the Nyquist frequency, beta 9), at any real source position. Played faster than unity, the cutoff falls to the output’s Nyquist frequency and the filter widens in proportion, as a falling rate does, so what the speed raises past the output’s Nyquist frequency is removed rather than folded back. Slower, the source’s Nyquist frequency bounds it, so no image of the source’s spectrum is heard.

Every weight comes from one table computed with libm’s portable functions, interpolated linearly, and every sum runs in one fixed order, so the same samples give bit-identical output natively and in wasm.

Implementations§

Source§

impl Interpolator

Source

pub fn new(speed: f64) -> Self

The filter for a clip playing speed source samples per output sample. A speed that is not a positive finite number takes the unity filter.

Source

pub const fn half_taps(&self) -> i64

Source samples on each side of a position that it weighs: an output at whole + fraction reads source samples whole - half + 1 ..= whole + half.

Source

pub fn weights(&self, fraction: f64, weights: &mut Vec<f64>)

Writes into weights the 2 * half weights, summing to one, of source samples whole - half + 1 ..= whole + half for a position fraction (in 0..1) past source sample whole.

Trait Implementations§

Source§

impl Clone for Interpolator

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Interpolator

Source§

impl Debug for Interpolator

Source§

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

Formats the value using the given formatter. Read more

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.