Struct rubato::FftFixedIn
source · [−]pub struct FftFixedIn<T> { /* private fields */ }
Expand description
A synchronous resampler that needs a fixed number of audio frames for input and returns a variable number of frames.
The resampling is done by FFT:ing the input data. The spectrum is then extended or truncated as well as multiplied with an antialiasing filter before it’s inverse transformed to get the resampled waveforms.
Implementations
sourceimpl<T> FftFixedIn<T> where
T: Sample,
impl<T> FftFixedIn<T> where
T: Sample,
sourcepub fn new(
fs_in: usize,
fs_out: usize,
chunk_size_in: usize,
sub_chunks: usize,
nbr_channels: usize
) -> Self
pub fn new(
fs_in: usize,
fs_out: usize,
chunk_size_in: usize,
sub_chunks: usize,
nbr_channels: usize
) -> Self
Create a new FftFixedOut
Parameters are:
fs_in
: Input sample rate.fs_out
: Output sample rate.chunk_size_out
: length of output data in frames.sub_chunks
: desired number of subchunks for processing, actual number used may be different.nbr_channels
: number of channels in input/output.
Trait Implementations
sourceimpl<T> Resampler<T> for FftFixedIn<T> where
T: Sample,
impl<T> Resampler<T> for FftFixedIn<T> where
T: Sample,
sourcefn nbr_frames_needed(&self) -> usize
fn nbr_frames_needed(&self) -> usize
Query for the number of frames needed for the next call to “process”.
sourcefn process<V: AsRef<[T]>>(
&mut self,
wave_in: &[V]
) -> ResampleResult<Vec<Vec<T>>>
fn process<V: AsRef<[T]>>(
&mut self,
wave_in: &[V]
) -> ResampleResult<Vec<Vec<T>>>
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”.
sourcefn set_resample_ratio(&mut self, _new_ratio: f64) -> ResampleResult<()>
fn set_resample_ratio(&mut self, _new_ratio: f64) -> ResampleResult<()>
Update the resample ratio. This is not supported by this resampler and always returns an error.
sourcefn 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. This is not supported by this resampler and always returns an error.
Auto Trait Implementations
impl<T> !RefUnwindSafe for FftFixedIn<T>
impl<T> Send for FftFixedIn<T> where
T: Send,
impl<T> Sync for FftFixedIn<T> where
T: Sync,
impl<T> Unpin for FftFixedIn<T> where
T: Unpin,
impl<T> !UnwindSafe for FftFixedIn<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, U> VecResampler<T> for U where
U: Resampler<T>,
impl<T, U> VecResampler<T> for U where
U: Resampler<T>,
sourcefn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>
fn process(&mut self, wave_in: &[Vec<T>]) -> ResampleResult<Vec<Vec<T>>>
Resample a chunk of audio. Input and output data is stored in vectors, where each element contains a vector with all samples for a single channel. Read more
sourcefn nbr_frames_needed(&self) -> usize
fn nbr_frames_needed(&self) -> usize
Query for the number of frames needed for the next call to “process”.
sourcefn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>
fn set_resample_ratio(&mut self, new_ratio: f64) -> ResampleResult<()>
Update the resample ratio.
sourcefn 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.