fixed_resample

Function resampling_channel

Source
pub fn resampling_channel<T: Sample>(
    in_sample_rate: u32,
    out_sample_rate: u32,
    num_channels: usize,
    out_max_block_frames: usize,
    config: ResamplingChannelConfig,
) -> (ResamplingProd<T>, ResamplingCons<T>)
Expand description

Create a new realtime-safe spsc channel for sending samples across streams.

If the input and output samples rates differ, then this will automatically resample the input stream to match the output stream. If the sample rates match, then no resampling will occur.

Internally this uses the ringbuf crate.

  • in_sample_rate - The sample rate of the input stream.
  • out_sample_rate - The sample rate of the output stream.
  • num_channels - The number of channels in the stream.
  • out_max_block_frames - The maximum number of frames that can be read in a single call to ResamplingCons::read.
  • config - Additional options for the resampling channel.

ยงPanics

Panics when any of the following are true:

  • in_sample_rate == 0
  • out_sample_rate == 0
  • num_channels == 0
  • out_max_block_frames == 0,
  • config.latency_seconds <= 0.0
  • config.capacity_seconds <= 0.0