1
0
Fork 0

Add a usage example to Buffer::iter_blocks()

This commit is contained in:
Robbert van der Helm 2022-03-01 16:16:13 +01:00
parent b177e3114c
commit e6292a4650

View file

@ -258,6 +258,20 @@ impl<'a> Buffer<'a> {
/// [crate::Smoother::next_block()]. Before using this, you will need to call /// [crate::Smoother::next_block()]. Before using this, you will need to call
/// [crate::Plugin::initialize_block_smoothers()] with the same `max_block_size` in your /// [crate::Plugin::initialize_block_smoothers()] with the same `max_block_size` in your
/// initialization function first. /// initialization function first.
///
/// You can use this to obtain block-slices from a buffer so you can pass them to a libraryq:
///
/// ```ignore
/// for block in buffer.iter_blocks(128) {
/// let mut block_channels = block.into_iter();
/// let stereo_slice = &[
/// block_channels.next().unwrap(),
/// block_channels.next().unwrap(),
/// ];
///
/// // Do something cool with `stereo_slice`
/// }
/// ````
pub fn iter_blocks<'slice>(&'slice mut self, max_block_size: usize) -> BlocksIter<'slice, 'a> { pub fn iter_blocks<'slice>(&'slice mut self, max_block_size: usize) -> BlocksIter<'slice, 'a> {
BlocksIter { BlocksIter {
buffers: self.output_slices.as_mut_slice(), buffers: self.output_slices.as_mut_slice(),