[][src]Trait rubato::Resampler

pub trait Resampler<T> {
    fn process(
        &mut self,
        wave_in: &[Vec<T>]
    ) -> Result<Vec<Vec<T>>, Box<dyn Error>>;
fn set_resample_ratio(
        &mut self,
        new_ratio: f64
    ) -> Result<(), Box<dyn Error>>;
fn set_resample_ratio_relative(
        &mut self,
        rel_ratio: f64
    ) -> Result<(), Box<dyn Error>>;
fn nbr_frames_needed(&self) -> usize; }

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>]) -> Result<Vec<Vec<T>>, Box<dyn Error>>

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 set_resample_ratio(&mut self, new_ratio: f64) -> Result<(), Box<dyn Error>>

Update the resample ratio.

fn set_resample_ratio_relative(
    &mut self,
    rel_ratio: f64
) -> Result<(), Box<dyn Error>>

Update the resample ratio relative to the original one.

fn nbr_frames_needed(&self) -> usize

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

Loading content...

Implementors

impl Resampler<f32> for FftFixedIn<f32>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

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

fn process(
    &mut self,
    wave_in: &[Vec<f32>]
) -> Result<Vec<Vec<f32>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The required input length is provided by the "nbr_frames_needed" function, and the output length is fixed.

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".

impl Resampler<f32> for FftFixedInOut<f32>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

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

fn process(
    &mut self,
    wave_in: &[Vec<f32>]
) -> Result<Vec<Vec<f32>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The input and output lengths are fixed.

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.

impl Resampler<f32> for FftFixedOut<f32>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

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

fn process(
    &mut self,
    wave_in: &[Vec<f32>]
) -> Result<Vec<Vec<f32>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The required input length is provided by the "nbr_frames_needed" function, and the output length is fixed.

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".

impl Resampler<f32> for SincFixedIn<f32>[src]

fn process(
    &mut self,
    wave_in: &[Vec<f32>]
) -> Result<Vec<Vec<f32>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The input length is fixed, and the output varies in length.

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 set_resample_ratio(&mut self, new_ratio: f64) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

Update the resample ratio relative to the original one

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.

impl Resampler<f32> for SincFixedOut<f32>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

Update the resample ratio relative to the original one

fn process(
    &mut self,
    wave_in: &[Vec<f32>]
) -> Result<Vec<Vec<f32>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The required input length is provided by the "nbr_frames_needed" function, and the output length is fixed.

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".

impl Resampler<f64> for FftFixedIn<f64>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

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

fn process(
    &mut self,
    wave_in: &[Vec<f64>]
) -> Result<Vec<Vec<f64>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The required input length is provided by the "nbr_frames_needed" function, and the output length is fixed.

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".

impl Resampler<f64> for FftFixedInOut<f64>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

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

fn process(
    &mut self,
    wave_in: &[Vec<f64>]
) -> Result<Vec<Vec<f64>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The input and output lengths are fixed.

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.

impl Resampler<f64> for FftFixedOut<f64>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

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

fn process(
    &mut self,
    wave_in: &[Vec<f64>]
) -> Result<Vec<Vec<f64>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The required input length is provided by the "nbr_frames_needed" function, and the output length is fixed.

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".

impl Resampler<f64> for SincFixedIn<f64>[src]

fn process(
    &mut self,
    wave_in: &[Vec<f64>]
) -> Result<Vec<Vec<f64>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The input length is fixed, and the output varies in length.

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 set_resample_ratio(&mut self, new_ratio: f64) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

Update the resample ratio relative to the original one

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.

impl Resampler<f64> for SincFixedOut<f64>[src]

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) -> Result<(), Box<dyn Error>>[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
) -> Result<(), Box<dyn Error>>
[src]

Update the resample ratio relative to the original one

fn process(
    &mut self,
    wave_in: &[Vec<f64>]
) -> Result<Vec<Vec<f64>>, Box<dyn Error>>
[src]

Resample a chunk of audio. The required input length is provided by the "nbr_frames_needed" function, and the output length is fixed.

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".

Loading content...