AUDIO
Source snapshot · 12 October 2026

API reference / ravet_signal::SincResampler

Struct SincResampler 

pub struct SincResampler { /* private fields */ }
Expand description

One-channel f64 arbitrary-ratio streaming converter, rate ratio 1/16..16. Preparation allocates a 1025-phase Blackman-windowed sinc table and history. Processing interpolates table phases and allocates nothing. Filter delay is (taps-1)/2 input samples; initial history is zero. This is a fixed quality profile, not a spectral rejection or callback deadline guarantee. Fixed rates use Self::new; Self::new_integer_rates selects an exact integer schedule; Self::new_variable prepares bounded live ppm adjustments with a conservative fixed cutoff and retained stream phase.

Implementations§

§

impl SincResampler

pub fn new( input_rate: f64, output_rate: f64, taps: usize, ) -> Result<Self, ResamplingError>

Finite positive rates and even tap count 16..256. Control-thread work. Rates are expressed in the same units; no hardware/format conversion.

pub fn new_integer_rates( input_rate: u32, output_rate: u32, taps: usize, ) -> Result<Self, ResamplingError>

Prepare a caller-selected exact integer-rate schedule. Positive u32 rates, ratio 1/16..16 and even 16..256 taps; coefficient/history preparation matches the fixed profile. Scheduling uses a bounded signed relative numerator, without duration-dependent floating recurrence. Only phase interpolation uses f64; numerical PCM can differ from new. This does not improve the spectral profile or establish device/callback deadlines. Nonzero live ppm adjustments reject; finite streams still require caller-supplied padding.

pub fn integer_position( &self, output_frame: u64, ) -> Result<IntegerResamplingPosition, ResamplingError>

Compute the exact next-output input coordinate without changing state. Integer profiles only; u128 input count includes explicit caller padding. No allocation, I/O, source validation or finite-file tail policy is implied.

pub fn prime_integer_at( &mut self, output_frame: u64, chronological_history: &[f64], ) -> Result<IntegerResamplingPosition, ResamplingError>

Prime an integer stream so its next sample is the specified output frame. Off-audio source-window preparation supplies exactly taps finite samples oldest-to-newest, ending at input coordinate C-1 from integer_position. Leading/trailing zeros and finite-file bounds belong to the caller. Invalid mode/history preserves all state. This operation allocates nothing and does not read, seek, authenticate source history or change coefficients/rates.

pub fn new_variable( input_rate: f64, output_rate: f64, taps: usize, maximum_adjustment_ppm: f64, ) -> Result<Self, ResamplingError>

Prepare a live-adjustable clock-drift profile. Maximum adjustment must be finite in (0,10000] ppm (one percent); the entire permitted input/ output step range must stay within 1/16..16. Filter cutoff uses the largest permitted step, avoiding live coefficient allocation. This is not an automatic drift estimator or a spectral/deadline guarantee.

pub fn validate_variable( input_rate: f64, output_rate: f64, taps: usize, maximum_adjustment_ppm: f64, ) -> Result<(), ResamplingError>

Check live-adjustable preparation bounds without allocating coefficient storage or mutating a stream. This does not prepare a converter or prove native device support. Rates are finite positive values in matching units.

pub fn set_rate_adjustment_ppm( &mut self, ppm: f64, ) -> Result<(), ResamplingError>

Change future output spacing without resetting history or pending phase. Positive ppm consumes input faster per output sample. The next output’s already scheduled position is retained; new spacing applies afterward. Reject before mutation. Fixed constructor accepts only zero adjustment. No smoothing/estimation is implicit; this operation allocates nothing.

pub fn rate_step(&self) -> f64

Current input samples per output sample, including live adjustment.

pub fn maximum_adjustment_ppm(&self) -> f64

pub fn latency_input_samples(&self) -> f64

pub fn reset(&mut self)

Clear stream state and zero history without reallocating coefficients. Retain the current rate adjustment; set zero explicitly to return nominal.

pub fn process( &mut self, input: &[f64], output: &mut [f64], ) -> ResamplingProgress

Consume/produce bounded prefixes, retaining pending output internally. Zero output capacity consumes nothing. Zero input may drain pending output. Output beyond produced is untouched. To flush a finite stream, supply explicit trailing zeros; this method does not invent input or final padding. Nonfinite audio propagates. Fixed construction retains its rate; the variable profile accepts only its prepared bounded ppm adjustments.

Trait Implementations§

§

impl Clone for SincResampler

§

fn clone(&self) -> SincResampler

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for SincResampler

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.