Function resampling_channel

Source
pub fn resampling_channel<T: Sample, const MAX_CHANNELS: usize>(
    num_channels: NonZeroUsize,
    in_sample_rate: u32,
    out_sample_rate: u32,
    config: ResamplingChannelConfig,
) -> (ResamplingProd<T, MAX_CHANNELS>, 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.
  • 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

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