Skip to main content

Resampler

Struct Resampler 

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

A band-limited converter from one sample rate to another.

Implementations§

Source§

impl Resampler

Source

pub fn new(source_rate: u32, target_rate: u32) -> Result<Self, ResampleError>

A converter from source_rate to target_rate.

Builds the whole coefficient table here, so call it off the real-time thread.

§Errors

Either rate is zero or above MAX_RESAMPLE_RATE, or the source rate is more than MAX_DOWNSAMPLE_FACTOR times the target rate.

Source

pub const fn source_rate(&self) -> u32

Source samples per second.

Source

pub const fn target_rate(&self) -> u32

Output samples per second.

Source

pub const fn is_identity(&self) -> bool

Whether the two rates are equal: output sample n is source sample n.

Source

pub fn half_taps(&self) -> i64

Source samples on each side of an output sample that it weighs.

Source

pub fn target_at_or_after(&self, source: i64) -> i64

The first output sample at or after source sample source.

Source

pub fn target_known_before(&self, source_end: i64) -> i64

The first output sample that weighs a source sample at or after source_end: every output before it is known once the source is known up to source_end.

Source

pub fn source_span(&self, target: Range<i64>) -> Range<i64> ⓘ

The source samples outputs target weigh.

Source

pub fn resample( &self, input: &[f32], input_start: i64, target_start: i64, output: &mut [f32], )

Writes outputs target_start .. into output from input, whose first sample is source sample input_start. The source is silent outside input.

Trait Implementations§

Source§

impl Clone for Resampler

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 Debug for Resampler

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.