pub trait Resampler<T>: Send {
fn process<V: AsRef<[T]>>(
&mut self,
wave_in: &[V]
) -> ResampleResult<Vec<Vec<T>>>;
fn nbr_frames_needed(&self) -> usize;
fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>;
fn set_resample_ratio_relative(
&mut self,
rel_ratio: f64
) -> ResampleResult<()>;
}
Expand description
A resampler that us used to resample a chunk of audio to a new sample rate. The rate can be adjusted as required.
Required methods
Resample a chunk of audio.
The input data is a slice, where each element of the slice is itself referenceable as a slice
(AsRef<[T]>
) which contains the samples for a single channel. Since Vec<T>
implements
AsRef<[T]>
, the input may simply be &*Vec<Vec<T>>
. The output data is a vector, where each element
of the vector is itself a vector which contains the samples for a single channel.
fn nbr_frames_needed(&self) -> usize
fn nbr_frames_needed(&self) -> usize
Query for the number of frames needed for the next call to “process”.
fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>
fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>
Update the resample ratio.
fn set_resample_ratio_relative(&mut self, rel_ratio: f64) -> ResampleResult<()>
fn set_resample_ratio_relative(&mut self, rel_ratio: f64) -> ResampleResult<()>
Update the resample ratio relative to the original one.