pub struct ResamplingCons<T: Sample> { /* private fields */ }
Expand description
The consumer end of a 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.
Implementations§
Source§impl<T: Sample> ResamplingCons<T>
impl<T: Sample> ResamplingCons<T>
Sourcepub fn num_channels(&self) -> NonZeroUsize
pub fn num_channels(&self) -> NonZeroUsize
The number of channels configured for this stream.
Sourcepub fn max_block_frames(&self) -> usize
pub fn max_block_frames(&self) -> usize
The maximum number of frames that can be read in a single call to
ResamplingCons::read
.
Sourcepub fn is_resampling(&self) -> bool
pub fn is_resampling(&self) -> bool
Returns true
if resampling is occurring, false
if the input and output
sample rates match.
Sourcepub fn output_delay(&self) -> usize
pub fn output_delay(&self) -> usize
Get the delay of the internal resampler, reported as a number of output frames.
If no resampler is active, then this will return 0
.
Sourcepub fn read(&mut self, output: &mut [T]) -> ReadStatus
pub fn read(&mut self, output: &mut [T]) -> ReadStatus
Read from the channel and store the results into the output buffer in interleaved format.
§Panics
Panics if the number of frames in output
is greater than
ResamplingCons::max_block_frames
.