Struct rubato::FftFixedOut
source · pub struct FftFixedOut<T> { /* private fields */ }
Expand description
A synchronous resampler that needs a varying number of audio frames for input and returns a fixed 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§
source§impl<T> FftFixedOut<T>where
T: Sample,
impl<T> FftFixedOut<T>where
T: Sample,
sourcepub fn new(
sample_rate_input: usize,
sample_rate_output: usize,
chunk_size_out: usize,
sub_chunks: usize,
nbr_channels: usize
) -> Result<Self, ResamplerConstructionError>
pub fn new( sample_rate_input: usize, sample_rate_output: usize, chunk_size_out: usize, sub_chunks: usize, nbr_channels: usize ) -> Result<Self, ResamplerConstructionError>
Create a new FftFixedOut.
Parameters are:
sample_rate_input
: Input sample rate, must be > 0.sample_rate_output
: Output sample rate, must be > 0.chunk_size_out
: length of output data in frames.sub_chunks
: desired number of subchunks for processing, actual number may be different.nbr_channels
: number of channels in input/output.
Trait Implementations§
source§impl<T> Resampler<T> for FftFixedOut<T>where
T: Sample,
impl<T> Resampler<T> for FftFixedOut<T>where
T: Sample,
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<()>
Update the resample ratio. This is not supported by this resampler and always returns ResampleError::SyncNotAdjustable.
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<()>
Update the resample ratio relative to the original one. This is not supported by this resampler and always returns ResampleError::SyncNotAdjustable.
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 input_frames_max(&self) -> usize
fn input_frames_max(&self) -> usize
Get the maximum number of input frames per channel the resampler could require.
source§fn input_frames_next(&self) -> usize
fn input_frames_next(&self) -> usize
Get the number of frames per channel needed for the next call to
process_into_buffer or process.
source§fn nbr_channels(&self) -> usize
fn nbr_channels(&self) -> usize
Get the maximum number of channels this Resampler is configured for.
source§fn output_frames_max(&self) -> usize
fn output_frames_max(&self) -> usize
Get the max number of output frames per channel.
source§fn output_frames_next(&self) -> usize
fn output_frames_next(&self) -> usize
Get the number of frames per channel that will be output from the next call to
process_into_buffer or process.
source§fn output_delay(&self) -> usize
fn output_delay(&self) -> usize
Get the delay for the resampler, reported as a number of output frames.
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>>>
This is a convenience wrapper for process_into_buffer
that allocates the output buffer with each call. For realtime applications, use
process_into_buffer with a buffer allocated by
output_buffer_allocate instead of this function.
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)>
This is a convenience method for processing the last frames at the end of a stream.
Use this when there are fewer frames remaining than what the resampler requires as input.
Calling this function is equivalent to padding the input buffer with zeros
to make it the right input length, and then calling process_into_buffer.
This method can also be called without any input frames, by providing
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.source§fn process_partial<V: AsRef<[T]>>(
&mut self,
wave_in: Option<&[V]>,
active_channels_mask: Option<&[bool]>
) -> ResampleResult<Vec<Vec<T>>>
fn process_partial<V: AsRef<[T]>>( &mut self, wave_in: Option<&[V]>, active_channels_mask: Option<&[bool]> ) -> ResampleResult<Vec<Vec<T>>>
This is a convenience method for processing the last frames at the end of a stream.
It is similar to process_partial_into_buffer
but allocates the output buffer with each call.
Note that this method allocates space for both input and output.
source§fn input_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
fn input_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
Convenience method for allocating an input buffer suitable for use with
process_into_buffer. The buffer’s capacity
is big enough to prevent allocating additional heap memory before any call to
process_into_buffer regardless of the current
resampling ratio. Read more
source§fn output_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
fn output_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
Convenience method for allocating an output buffer suitable for use with
process_into_buffer. The buffer’s capacity
is big enough to prevent allocating additional heap memory during any call to
process_into_buffer regardless of the current
resampling ratio. Read more
Auto Trait Implementations§
impl<T> !RefUnwindSafe for FftFixedOut<T>
impl<T> Send for FftFixedOut<T>where
T: Send,
impl<T> Sync for FftFixedOut<T>where
T: Sync,
impl<T> Unpin for FftFixedOut<T>where
T: Unpin,
impl<T> !UnwindSafe for FftFixedOut<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T, U> VecResampler<T> for U
impl<T, U> VecResampler<T> for U
source§fn process(
&mut self,
wave_in: &[Vec<T>],
active_channels_mask: Option<&[bool]>
) -> Result<Vec<Vec<T>>, ResampleError>
fn process( &mut self, wave_in: &[Vec<T>], active_channels_mask: Option<&[bool]> ) -> Result<Vec<Vec<T>>, ResampleError>
Refer to Resampler::process.
source§fn process_into_buffer(
&mut self,
wave_in: &[Vec<T>],
wave_out: &mut [Vec<T>],
active_channels_mask: Option<&[bool]>
) -> Result<(usize, usize), ResampleError>
fn process_into_buffer( &mut self, wave_in: &[Vec<T>], wave_out: &mut [Vec<T>], active_channels_mask: Option<&[bool]> ) -> Result<(usize, usize), ResampleError>
Refer to Resampler::process_into_buffer.
source§fn process_partial_into_buffer(
&mut self,
wave_in: Option<&[Vec<T>]>,
wave_out: &mut [Vec<T>],
active_channels_mask: Option<&[bool]>
) -> Result<(usize, usize), ResampleError>
fn process_partial_into_buffer( &mut self, wave_in: Option<&[Vec<T>]>, wave_out: &mut [Vec<T>], active_channels_mask: Option<&[bool]> ) -> Result<(usize, usize), ResampleError>
Refer to Resampler::process_partial_into_buffer.
source§fn process_partial(
&mut self,
wave_in: Option<&[Vec<T>]>,
active_channels_mask: Option<&[bool]>
) -> Result<Vec<Vec<T>>, ResampleError>
fn process_partial( &mut self, wave_in: Option<&[Vec<T>]>, active_channels_mask: Option<&[bool]> ) -> Result<Vec<Vec<T>>, ResampleError>
Refer to Resampler::process_partial.
source§fn output_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
fn output_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
Refer to Resampler::output_buffer_allocate.
source§fn output_frames_next(&self) -> usize
fn output_frames_next(&self) -> usize
Refer to Resampler::output_frames_next.
source§fn output_frames_max(&self) -> usize
fn output_frames_max(&self) -> usize
Refer to Resampler::output_frames_max.
source§fn input_frames_next(&self) -> usize
fn input_frames_next(&self) -> usize
Refer to Resampler::input_frames_next.
source§fn output_delay(&self) -> usize
fn output_delay(&self) -> usize
Refer to Resampler::output_delay.
source§fn nbr_channels(&self) -> usize
fn nbr_channels(&self) -> usize
Refer to Resampler::nbr_channels.
source§fn input_frames_max(&self) -> usize
fn input_frames_max(&self) -> usize
Refer to Resampler::input_frames_max.
source§fn input_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
fn input_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>
Refer to Resampler::input_buffer_allocate.
source§fn set_resample_ratio(
&mut self,
new_ratio: f64,
ramp: bool
) -> Result<(), ResampleError>
fn set_resample_ratio( &mut self, new_ratio: f64, ramp: bool ) -> Result<(), ResampleError>
Refer to Resampler::set_resample_ratio.
source§fn set_resample_ratio_relative(
&mut self,
rel_ratio: f64,
ramp: bool
) -> Result<(), ResampleError>
fn set_resample_ratio_relative( &mut self, rel_ratio: f64, ramp: bool ) -> Result<(), ResampleError>
Refer to Resampler::set_resample_ratio_relative.