Skip to main content

resampling_channel

Function resampling_channel 

Source
pub fn resampling_channel<T: Sample>(
    num_channels: usize,
    in_sample_rate: u32,
    out_sample_rate: u32,
    push_interleave_only: bool,
    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 (unless the “resample” feature is disabled). If the sample rates match, then no resampling will occur.

Internally this uses the rubato and ringbuf crates.

  • 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.
  • push_interleave_only - If you are NOT using ResamplingProd::push, then you can set this to true to save a bit of memory. Otherwise, set this to false.
  • 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
  • config.latency_seconds <= 0.0
  • config.capacity_seconds <= 0.0
  • config.output_chunk_size == 0

If the “resampler” feature is disabled, then this will also panic if in_sample_rate != out_sample_rate.