pub struct RubatoResampler { /* private fields */ }Expand description
RT-safe resampler backed by the rubato Fft synchronous resampler.
It operates at a fixed input ratio (FixedSync::Input). On the processing
path (process_into_buffer) it wraps the
caller-provided planar-flat slice directly with a SequentialSlice adapter
and hands it to rubato zero-copy and allocation-free.
§Panics
No method on this type panics. Every error on the processing path is
returned as a ResampleError.
Implementations§
Source§impl RubatoResampler
impl RubatoResampler
Sourcepub fn new(
input_rate: f64,
output_rate: f64,
channels: usize,
chunk_size: usize,
) -> Result<Self, ResampleError>
pub fn new( input_rate: f64, output_rate: f64, channels: usize, chunk_size: usize, ) -> Result<Self, ResampleError>
Creates a new resampler. Call this before entering the RT thread so that all internal state is prepared.
input_rate/output_rate must be positive finite values (>= 1.0 Hz,
<= MAX_RATE, representable as integer Hz without loss). channels >= 1
and chunk_size >= 1 are required.
§Errors
- rate <= 0, non-finite, or >
MAX_RATE->ResampleError::InvalidSampleRate. channels == 0->ResampleError::InvalidChannelCount.chunk_size == 0->ResampleError::InvalidChunkSize.- rubato
Fftconstruction failure ->ResampleError::ResampleFailed.
Sourcepub fn input_chunk_size(&self) -> usize
pub fn input_chunk_size(&self) -> usize
Returns the fixed number of input frames (per channel).
Sourcepub fn output_frames_max(&self) -> usize
pub fn output_frames_max(&self) -> usize
Returns the upper bound on output frames (per channel). The RT caller must pre-allocate the output buffer to at least this size.
Sourcepub fn input_rate(&self) -> f64
pub fn input_rate(&self) -> f64
Returns the input sample rate (Hz).
Sourcepub fn output_rate(&self) -> f64
pub fn output_rate(&self) -> f64
Returns the output sample rate (Hz).
Sourcepub fn output_delay(&self) -> usize
pub fn output_delay(&self) -> usize
Returns the resampler’s group delay, in output frames.
rubato Fft introduces a fixed delay equal to half the internal FFT
block size, expressed in output frames. For offline / full-clip
processing the caller may trim this many leading output frames to align
output with input. For RT streaming the caller absorbs the delay through
buffering.
This is a read-only query, so it is safe on the RT path (no allocation, no locking).
Trait Implementations§
Source§impl Debug for RubatoResampler
impl Debug for RubatoResampler
Source§impl Resampler for RubatoResampler
impl Resampler for RubatoResampler
Source§fn process_into_buffer(
&mut self,
input: &[f32],
output: &mut [f32],
) -> Result<usize, ResampleError>
fn process_into_buffer( &mut self, input: &[f32], output: &mut [f32], ) -> Result<usize, ResampleError>
output buffer
(RT-safe, allocation-free). Read more