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
impl PolyphaseResampler
Sourcepub fn new(
input_rate_hz: u32,
output_rate_hz: u32,
channels: usize,
policy: ResamplerPolicy,
) -> Result<Self, ResampleError>
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.
Sourcepub fn input_rate_hz(&self) -> u32
pub fn input_rate_hz(&self) -> u32
Returns the configured input rate in hertz.
Sourcepub fn output_rate_hz(&self) -> u32
pub fn output_rate_hz(&self) -> u32
Returns the configured output rate in hertz.
Sourcepub fn latency_input_frames(&self) -> usize
pub fn latency_input_frames(&self) -> usize
Returns the fixed source-rate latency of the causal filter.
Sourcepub fn required_output_frames(
&self,
input_frames: usize,
) -> Result<usize, ResampleError>
pub fn required_output_frames( &self, input_frames: usize, ) -> Result<usize, ResampleError>
Returns the output frames that the next input block will produce.
Sourcepub fn process_interleaved(
&mut self,
input: &[f32],
output: &mut [f32],
) -> Result<ResampleReport, ResampleError>
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.
Trait Implementations§
Source§impl Clone for PolyphaseResampler
impl Clone for PolyphaseResampler
Source§fn clone(&self) -> PolyphaseResampler
fn clone(&self) -> PolyphaseResampler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more