Skip to main content

Adjustable

Trait Adjustable 

Source
pub trait Adjustable<T>: Resampler<T>
where T: Sample,
{ // Required methods fn set_resample_ratio( &mut self, new_ratio: f64, ramp: bool, ) -> ResampleResult<()>; fn set_resample_ratio_relative( &mut self, rel_ratio: f64, ramp: bool, ) -> ResampleResult<()>; }
Expand description

A Resampler whose resample ratio can be changed after construction.

Implemented by the asynchronous resamplers. From a &mut dyn Resampler it can be recovered with Resampler::as_adjustable.

The ratio is typically driven by a feedback loop that measures a buffer fill and nudges it to track a small clock difference. Slip carries a complete worked example of such a loop; the same pattern applies to any Adjustable resampler, including Async.

Required Methods§

Source

fn set_resample_ratio( &mut self, new_ratio: f64, ramp: bool, ) -> ResampleResult<()>

Update the resample ratio.

The ratio must be within original / maximum to original * maximum, where the original and maximum are the resampling ratios that were provided to the constructor. Trying to set the ratio outside these bounds will return ResampleError::RatioOutOfBounds.

If the argument ramp is set to true, the ratio will be ramped from the old to the new value during processing of the next chunk. This allows smooth transitions from one ratio to another. If ramp is false, the new ratio will be applied from the start of the next chunk.

Source

fn set_resample_ratio_relative( &mut self, rel_ratio: f64, ramp: bool, ) -> ResampleResult<()>

Update the resample ratio as a factor relative to the original one.

The relative ratio must be within 1 / maximum to maximum, where maximum is the maximum resampling ratio that was provided to the constructor. Trying to set the ratio outside these bounds will return ResampleError::RatioOutOfBounds.

Ratios above 1.0 slow down the output and lower the pitch, while ratios below 1.0 speed up the output and raise the pitch.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Adjustable<T> for Async<T>
where T: Sample,

Source§

impl<T> Adjustable<T> for Slip<T>
where T: Sample,