pub struct Resampler { /* private fields */ }Expand description
Audio resampler that accepts interleaved f32 samples.
Internally buffers partial chunks and drives rubato’s fixed-input-size resampler, producing interleaved f32 output.
Implementations§
Source§impl Resampler
impl Resampler
Sourcepub fn new(
from_rate: u32,
to_rate: u32,
channels: usize,
quality: Quality,
) -> Result<Self>
pub fn new( from_rate: u32, to_rate: u32, channels: usize, quality: Quality, ) -> Result<Self>
Create a new resampler.
from_rate/to_rate— input / output sample rates in Hz.channels— number of interleaved channels (must be >= 1).quality— algorithm selection (seeQuality).
Sourcepub fn process(&mut self, input: &[f32]) -> Result<Vec<f32>>
pub fn process(&mut self, input: &[f32]) -> Result<Vec<f32>>
Feed interleaved f32 samples and receive resampled interleaved output.
Input length must be a multiple of channels. Output length will also
be a multiple of channels.
The resampler buffers internally, so output may be shorter or longer
than a naive ratio calculation — call flush at the end
to drain remaining samples.
Sourcepub fn flush(&mut self) -> Result<Vec<f32>>
pub fn flush(&mut self) -> Result<Vec<f32>>
Flush remaining buffered samples by zero-padding to a full chunk.
Call this once after the last process() call to retrieve the tail
of the resampled signal.
Sourcepub fn output_frames_estimate(&self, input_frames: usize) -> usize
pub fn output_frames_estimate(&self, input_frames: usize) -> usize
Estimate the number of output frames for a given number of input frames.
Auto Trait Implementations§
impl Freeze for Resampler
impl !RefUnwindSafe for Resampler
impl Send for Resampler
impl !Sync for Resampler
impl Unpin for Resampler
impl UnsafeUnpin for Resampler
impl !UnwindSafe for Resampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more