Struct Sinc Resampler
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
impl SincResampler
pub fn new(
input_rate: f64,
output_rate: f64,
taps: usize,
) -> Result<Self, ResamplingError>
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>
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>
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>
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>
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>
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>
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 maximum_adjustment_ppm(&self) -> f64
pub fn latency_input_samples(&self) -> f64
pub fn reset(&mut self)
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
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
impl Clone for SincResampler
§fn clone(&self) -> SincResampler
fn clone(&self) -> SincResampler
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more