Skip to main content

PolyphaseResampler

Struct PolyphaseResampler 

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

Streaming windowed-sinc polyphase resampler with fixed callback state.

Construction allocates the coefficient bank and the interleaved history ring. process_interleaved writes into caller storage and performs no allocation, locking, or I/O. The filter is causal: the first output is delayed until the right half of its impulse response is available, and callers may append zero input to drain a finite stream.

Implementations§

Source§

impl PolyphaseResampler

Source

pub fn new( input_rate_hz: u32, output_rate_hz: u32, channels: usize, policy: ResamplerPolicy, ) -> Result<Self, ResampleError>

Builds a fixed-state resampler and precomputes its Blackman-windowed low-pass coefficient bank.

Source

pub fn input_rate_hz(&self) -> u32

Returns the configured input rate in hertz.

Source

pub fn output_rate_hz(&self) -> u32

Returns the configured output rate in hertz.

Source

pub fn channels(&self) -> usize

Returns the interleaved channel count.

Source

pub fn latency_input_frames(&self) -> usize

Returns the fixed source-rate latency of the causal filter.

Source

pub fn required_output_frames( &self, input_frames: usize, ) -> Result<usize, ResampleError>

Returns the output frames that the next input block will produce.

Source

pub fn process_interleaved( &mut self, input: &[f32], output: &mut [f32], ) -> Result<ResampleReport, ResampleError>

Consumes interleaved source frames and writes every now-available resampled frame into output.

The call fails before consuming input when the buffers are misaligned, the input bound is exceeded, or output storage is too small.

Source

pub fn reset(&mut self)

Clears time and sample history while retaining every allocation.

Trait Implementations§

Source§

impl Clone for PolyphaseResampler

Source§

fn clone(&self) -> PolyphaseResampler

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 PolyphaseResampler

Source§

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

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

impl PartialEq for PolyphaseResampler

Source§

fn eq(&self, other: &PolyphaseResampler) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PolyphaseResampler

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.