Skip to main content

Resampler

Struct Resampler 

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

A streaming rational resampler for any number of channels that advance together.

Planar buffers (one Vec<f64> per channel) are used so the caller can reuse them: nothing in Resampler::process allocates, provided the input block has at most max_block frames and the output buffers are long enough (Resampler::output_len_for).

Implementations§

Source§

impl Resampler

Source

pub fn new( from_hz: u32, to_hz: u32, channels: usize, quality: Quality, max_block: usize, ) -> Result<Self, ConvertError>

A converter from from_hz to to_hz for channels channels, taking at most max_block frames per call.

Source

pub fn info(&self) -> &FilterInfo

Source

pub fn channels(&self) -> usize

Source

pub fn delay_frames(&self) -> usize

Input frames the converter holds back: the algorithmic latency. Output sample n is aligned with input time n * M / L and is produced once the input has reached delay_frames() frames past it.

Source

pub fn pad_frames(&self) -> usize

Zero frames to feed after the last input to flush the tail out.

Source

pub fn frames_in(&self) -> u64

Input frames fed since the start or the last reset.

Source

pub fn frames_out(&self) -> u64

Output frames produced since the start or the last reset.

Source

pub fn reset(&mut self)

Forgets the signal: the next input is the start of a new stream.

Source

pub fn output_len_for(&self, input_frames: usize) -> usize

How many output frames feeding input_frames more input produces, exactly.

Source

pub fn max_input_for_output(&self, output_frames: usize) -> usize

The most input frames that can be fed so that no more than output_frames come out.

Source

pub fn process( &mut self, input: &[Vec<f64>], n: usize, output: &mut [Vec<f64>], ) -> usize

Feeds n frames (input[c][..n] for each channel) and writes the output frames to the front of output[c]; returns how many (Resampler::output_len_for). n must be at most max_block and every output[c] at least that long.

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> 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, 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.