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
impl Resampler
Sourcepub fn new(
from_hz: u32,
to_hz: u32,
channels: usize,
quality: Quality,
max_block: usize,
) -> Result<Self, ConvertError>
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.
pub fn info(&self) -> &FilterInfo
pub fn channels(&self) -> usize
Sourcepub fn delay_frames(&self) -> usize
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.
Sourcepub fn pad_frames(&self) -> usize
pub fn pad_frames(&self) -> usize
Zero frames to feed after the last input to flush the tail out.
Sourcepub fn frames_out(&self) -> u64
pub fn frames_out(&self) -> u64
Output frames produced since the start or the last reset.
Sourcepub fn output_len_for(&self, input_frames: usize) -> usize
pub fn output_len_for(&self, input_frames: usize) -> usize
How many output frames feeding input_frames more input produces, exactly.
Sourcepub fn max_input_for_output(&self, output_frames: usize) -> usize
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.
Sourcepub fn process(
&mut self,
input: &[Vec<f64>],
n: usize,
output: &mut [Vec<f64>],
) -> usize
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.