Trait rubato::Resampler[][src]

pub trait Resampler<T> {
    fn process(&mut self, wave_in: &[Vec<T>]) -> 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<()>; }

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

fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>[src]

Resample a chunk of audio. Input and output data is stored in a vector, where each element contains a vector with all samples for a single channel.

fn nbr_frames_needed(&self) -> usize[src]

Query for the number of frames needed for the next call to “process”.

fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio.

fn set_resample_ratio_relative(&mut self, rel_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio relative to the original one.

Loading content...

Implementors

impl<T> Resampler<T> for FftFixedIn<T> where
    T: Sample
[src]

fn nbr_frames_needed(&self) -> usize[src]

Query for the number of frames needed for the next call to “process”.

fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>[src]

Resample a chunk of audio. The required input length is provided by the “nbr_frames_needed” function, and the output length is fixed. If the waveform for a channel is empty, this channel will be ignored and produce a corresponding empty output waveform.

Errors

The function returns an error if the length of the input data is not equal to the number of channels defined when creating the instance, and the number of audio frames given by “nbr_frames_needed”.

fn set_resample_ratio(&mut self, _new_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio. This is not supported by this resampler and always returns an error.

fn set_resample_ratio_relative(&mut self, _rel_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio relative to the original one. This is not supported by this resampler and always returns an error.

impl<T> Resampler<T> for FftFixedInOut<T> where
    T: Sample
[src]

fn nbr_frames_needed(&self) -> usize[src]

Query for the number of frames needed for the next call to “process”.

fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>[src]

Resample a chunk of audio. The input and output lengths are fixed. If the waveform for a channel is empty, this channel will be ignored and produce a corresponding empty output waveform.

Errors

The function returns an error if the size of the input data is not equal to the number of channels and input size defined when creating the instance.

fn set_resample_ratio(&mut self, _new_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio. This is not supported by this resampler and always returns an error.

fn set_resample_ratio_relative(&mut self, _rel_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio relative to the original one. This is not supported by this resampler and always returns an error.

impl<T> Resampler<T> for FftFixedOut<T> where
    T: Sample
[src]

fn nbr_frames_needed(&self) -> usize[src]

Query for the number of frames needed for the next call to “process”.

fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>[src]

Resample a chunk of audio. The required input length is provided by the “nbr_frames_needed” function, and the output length is fixed. If the waveform for a channel is empty, this channel will be ignored and produce a corresponding empty output waveform.

Errors

The function returns an error if the length of the input data is not equal to the number of channels defined when creating the instance, and the number of audio frames given by “nbr_frames_needed”.

fn set_resample_ratio(&mut self, _new_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio. This is not supported by this resampler and always returns an error.

fn set_resample_ratio_relative(&mut self, _rel_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio relative to the original one. This is not supported by this resampler and always returns an error.

impl<T> Resampler<T> for SincFixedIn<T> where
    T: Sample
[src]

fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>[src]

Resample a chunk of audio. The input length is fixed, and the output varies in length. If the waveform for a channel is empty, this channel will be ignored and produce a corresponding empty output waveform.

Errors

The function returns an error if the length of the input data is not equal to the number of channels and chunk size defined when creating the instance.

fn nbr_frames_needed(&self) -> usize[src]

Query for the number of frames needed for the next call to “process”. Will always return the chunk_size defined when creating the instance.

fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio. New value must be within +-10% of the original one

fn set_resample_ratio_relative(&mut self, rel_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio relative to the original one

impl<T> Resampler<T> for SincFixedOut<T> where
    T: Sample
[src]

fn nbr_frames_needed(&self) -> usize[src]

Query for the number of frames needed for the next call to “process”.

fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>[src]

Resample a chunk of audio. The required input length is provided by the “nbr_frames_needed” function, and the output length is fixed. If the waveform for a channel is empty, this channel will be ignored and produce a corresponding empty output waveform.

Errors

The function returns an error if the length of the input data is not equal to the number of channels defined when creating the instance, and the number of audio frames given by “nbr_frames_needed”.

fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio. New value must be within +-10% of the original one

fn set_resample_ratio_relative(&mut self, rel_ratio: f64) -> ResampleResult<()>[src]

Update the resample ratio relative to the original one

Loading content...