pub struct Buffer<T: Float> { /* private fields */ }Expand description
Single-channel delay buffer
Access is used with buffer[index], relative to the internal read/write position (“head”).
This head is moved using buffer.advance(1) (or buffer.advance(n)), such that
buffer[1] == buffer.advance(1)[0].
The capacity includes both positive and negative indices. For example, a capacity of 100 would support using any of the ranges:
buffer[-99]tobuffer[0]buffer[-50]tobuffer[49]buffer[0]tobuffer[99]
Although buffers are usually used with historical samples accessed using negative indices
e.g. buffer[-10], you could equally use it flipped around (moving the head backwards
through the buffer using buffer.advance(-1)).
Implementations§
Source§impl<T: Float> Buffer<T>
impl<T: Float> Buffer<T>
Sourcepub fn new(min_capacity: usize) -> Self
pub fn new(min_capacity: usize) -> Self
Create a new buffer with the specified minimum capacity
Sourcepub fn resize(&mut self, min_capacity: usize, value: T)
pub fn resize(&mut self, min_capacity: usize, value: T)
Resize the buffer to have at least the specified capacity
Sourcepub fn advance(&mut self, amount: isize) -> &mut Self
pub fn advance(&mut self, amount: isize) -> &mut Self
Advance the buffer position by the specified amount
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Buffer<T>
impl<T> RefUnwindSafe for Buffer<T>where
T: RefUnwindSafe,
impl<T> Send for Buffer<T>where
T: Send,
impl<T> Sync for Buffer<T>where
T: Sync,
impl<T> Unpin for Buffer<T>where
T: Unpin,
impl<T> UnwindSafe for Buffer<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more