pub struct SincFixedIn<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 creating a number of intermediate points (defined by oversampling_factor) by sinc interpolation. The new samples are then calculated by interpolating between these points.

The resampling ratio can be freely adjusted within the range specified to the constructor. Adjusting the ratio does not recalculate the sinc functions used by the anti-aliasing filter. This causes no issue when increasing the ratio (which slows down the output). However when decreasing more than a few percent (or speeding up the output), the filters can no longer suppress all aliasing and this may lead to some artefacts. Higher maximum ratios require more memory to be allocated by Resampler::output_buffer_allocate.

Implementations

Create a new SincFixedIn

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 to resample_ratio, must be >= 1.0. The minimum relative ratio is the reciprocal of the maximum. For example, with max_resample_ratio_relative of 10.0, the ratio can be set between resample_ratio * 10.0 and resample_ratio / 10.0.
  • parameters: Parameters for interpolation, see InterpolationParameters
  • chunk_size: size of input data in frames
  • nbr_channels: number of channels in input/output

Create a new SincFixedIn using an existing Interpolator

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 to resample_ratio, must be >= 1.0. The minimum relative ratio is the reciprocal of the maximum. For example, with max_resample_ratio_relative of 10.0, the ratio can be set between resample_ratio * 10.0 and resample_ratio / 10.0.
  • interpolation_type: Parameters for interpolation, see InterpolationParameters
  • interpolator: The interpolator to use
  • chunk_size: size of output data in frames
  • nbr_channels: number of channels in input/output

Trait Implementations

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

Get the max number of output frames per channel

Get the number of frames per channel that will be output from the next call to process_into_buffer or process Read more

Get the maximum number of channels this Resampler is configured for

Get the maximum number of input frames per channel the resampler could require

Get the number of frames per channel needed for the next call to process_into_buffer or process Read more

Update the resample ratio Read more

Update the resample ratio as a factor relative to the original one Read more

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. Read more

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

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.