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,

source

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,

source§

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<()>

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)>

Resample a buffer of audio to a pre-allocated output buffer. Use this in real-time applications where the unpredictable time required to allocate memory from the heap can cause glitches. If this is not a problem, you may use the process method instead. Read more
source§

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

Get the number of frames per channel needed for the next call to process_into_buffer or process.
source§

fn nbr_channels(&self) -> usize

Get the maximum number of channels this Resampler is configured for.
source§

fn output_frames_max(&self) -> usize

Get the max number of output frames per channel.
source§

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

Get the delay for the resampler, reported as a number of output frames.
source§

fn reset(&mut self)

Reset the resampler state and clear all internal buffers.
source§

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)>

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

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

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

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> VecResampler<T> for U
where U: Resampler<T>, T: Sample,

source§

fn process( &mut self, wave_in: &[Vec<T>], active_channels_mask: Option<&[bool]> ) -> Result<Vec<Vec<T>>, ResampleError>

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>

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>

source§

fn process_partial( &mut self, wave_in: Option<&[Vec<T>]>, active_channels_mask: Option<&[bool]> ) -> Result<Vec<Vec<T>>, ResampleError>

source§

fn output_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>

source§

fn output_frames_next(&self) -> usize

source§

fn output_frames_max(&self) -> usize

source§

fn input_frames_next(&self) -> usize

source§

fn output_delay(&self) -> usize

source§

fn nbr_channels(&self) -> usize

source§

fn input_frames_max(&self) -> usize

source§

fn input_buffer_allocate(&self, filled: bool) -> Vec<Vec<T>>

source§

fn set_resample_ratio( &mut self, new_ratio: f64, ramp: bool ) -> Result<(), ResampleError>

source§

fn set_resample_ratio_relative( &mut self, rel_ratio: f64, ramp: bool ) -> Result<(), ResampleError>