Struct rubato::FastFixedIn
source · pub struct FastFixedIn<T> { /* private fields */ }
Expand description
An asynchronous resampler that accepts a fixed number of audio frames for input and returns a variable number of frames.
The resampling is done by interpolating between the input samples by fitting polynomials. The polynomial degree can selected, see PolynomialDegree for the available options.
Note that no anti-aliasing filter is used. This makes it run considerably faster than the corresponding SincFixedIn, which performs anti-aliasing filtering. The price is that the resampling creates some artefacts in the output, mainly at higher frequencies. Use SincFixedIn if this can not be tolerated.
The resampling ratio can be freely adjusted within the range specified to the constructor. Higher maximum ratios require more memory to be allocated by Resampler::output_buffer_allocate.
Implementations§
source§impl<T> FastFixedIn<T>where
T: Sample,
impl<T> FastFixedIn<T>where
T: Sample,
sourcepub fn new(
resample_ratio: f64,
max_resample_ratio_relative: f64,
interpolation_type: PolynomialDegree,
chunk_size: usize,
nbr_channels: usize
) -> Result<Self, ResamplerConstructionError>
pub fn new( resample_ratio: f64, max_resample_ratio_relative: f64, interpolation_type: PolynomialDegree, chunk_size: usize, nbr_channels: usize ) -> Result<Self, ResamplerConstructionError>
Create a new FastFixedIn.
Parameters are:
resample_ratio
: Starting ratio between output and input sample rates, must be > 0.max_resample_ratio_relative
: Maximum ratio that can be set with Resampler::set_resample_ratio relative toresample_ratio
, must be >= 1.0. The minimum relative ratio is the reciprocal of the maximum. For example, withmax_resample_ratio_relative
of 10.0, the ratio can be set betweenresample_ratio * 10.0
andresample_ratio / 10.0
.interpolation_type
: Degree of polynomial used for interpolation, see PolynomialDegree.chunk_size
: Size of input data in frames.nbr_channels
: Number of channels in input/output.
Trait Implementations§
source§impl<T> Resampler<T> for FastFixedIn<T>where
T: Sample,
impl<T> Resampler<T> for FastFixedIn<T>where
T: Sample,
source§fn process_into_buffer<Vin: AsRef<[T]>, Vout: AsMut<[T]>>(
&mut self,
wave_in: &[Vin],
wave_out: &mut [Vout],
active_channels_mask: Option<&[bool]>
) -> ResampleResult<(usize, usize)>
fn process_into_buffer<Vin: AsRef<[T]>, Vout: AsMut<[T]>>( &mut self, wave_in: &[Vin], wave_out: &mut [Vout], active_channels_mask: Option<&[bool]> ) -> ResampleResult<(usize, usize)>
source§fn output_frames_max(&self) -> usize
fn output_frames_max(&self) -> usize
source§fn output_frames_next(&self) -> usize
fn output_frames_next(&self) -> usize
source§fn output_delay(&self) -> usize
fn output_delay(&self) -> usize
source§fn nbr_channels(&self) -> usize
fn nbr_channels(&self) -> usize
source§fn input_frames_max(&self) -> usize
fn input_frames_max(&self) -> usize
source§fn input_frames_next(&self) -> usize
fn input_frames_next(&self) -> usize
source§fn set_resample_ratio(
&mut self,
new_ratio: f64,
ramp: bool
) -> ResampleResult<()>
fn set_resample_ratio( &mut self, new_ratio: f64, ramp: bool ) -> ResampleResult<()>
source§fn set_resample_ratio_relative(
&mut self,
rel_ratio: f64,
ramp: bool
) -> ResampleResult<()>
fn set_resample_ratio_relative( &mut self, rel_ratio: f64, ramp: bool ) -> ResampleResult<()>
source§fn process<V: AsRef<[T]>>(
&mut self,
wave_in: &[V],
active_channels_mask: Option<&[bool]>
) -> ResampleResult<Vec<Vec<T>>>
fn process<V: AsRef<[T]>>( &mut self, wave_in: &[V], active_channels_mask: Option<&[bool]> ) -> ResampleResult<Vec<Vec<T>>>
source§fn process_partial_into_buffer<Vin: AsRef<[T]>, Vout: AsMut<[T]>>(
&mut self,
wave_in: Option<&[Vin]>,
wave_out: &mut [Vout],
active_channels_mask: Option<&[bool]>
) -> ResampleResult<(usize, usize)>
fn process_partial_into_buffer<Vin: AsRef<[T]>, Vout: AsMut<[T]>>( &mut self, wave_in: Option<&[Vin]>, wave_out: &mut [Vout], active_channels_mask: Option<&[bool]> ) -> ResampleResult<(usize, usize)>
None
as input buffer.
This can be utilized to push any remaining delayed frames out from the internal buffers.
Note that this method allocates space for a temporary input buffer.
Real-time applications should instead call process_into_buffer
with a zero-padded pre-allocated input buffer.