Skip to main content

RubatoResampler

Struct RubatoResampler 

Source
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

Source

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
Source

pub fn input_chunk_size(&self) -> usize

Returns the fixed number of input frames (per channel).

Source

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.

Source

pub fn channels(&self) -> usize

Returns the channel count.

Source

pub fn input_rate(&self) -> f64

Returns the input sample rate (Hz).

Source

pub fn output_rate(&self) -> f64

Returns the output sample rate (Hz).

Source

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

Source§

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

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

impl Resampler for RubatoResampler

Source§

fn process_into_buffer( &mut self, input: &[f32], output: &mut [f32], ) -> Result<usize, ResampleError>

Writes resampled samples into the pre-allocated output buffer (RT-safe, allocation-free). Read more
Source§

fn set_rate(&mut self, input_rate: f64, output_rate: f64)

Changes the input/output sample rates. NOT RT-safe — allocates (call only between audio cycles). Read more

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> 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, 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.