pub struct TapeLoop<T> { /* private fields */ }Expand description
Heap-allocated ring buffer for tape delay — single-threaded.
Unlike DelayLine, TapeLoop does NOT use const generics
for its capacity — the buffer is allocated on the heap at runtime.
This allows arbitrarily large delay lines (millions of samples) without
stack overflow.
§Thread safety
TapeLoop is not thread-safe. It uses plain T, not AtomicCell,
because it is only accessed from the single signal thread.
§Example
use rill_core::buffer::TapeLoop;
let mut tape = TapeLoop::<f32>::new(96000).unwrap();
tape.write(0.5);
let sample = tape.read(100);Implementations§
Source§impl<T: Transcendental> TapeLoop<T>
impl<T: Transcendental> TapeLoop<T>
Sourcepub fn new(capacity: usize) -> Option<Self>
pub fn new(capacity: usize) -> Option<Self>
Allocate a new tape loop with the given capacity (in samples).
Sourcepub fn read(&self, delay: usize) -> T
pub fn read(&self, delay: usize) -> T
Read a sample at delay samples behind the write position.
Sourcepub fn read_interpolated(&self, delay: f64) -> T
pub fn read_interpolated(&self, delay: f64) -> T
Read with linear interpolation between samples.
Sourcepub fn write_block(&mut self, block: &[T])
pub fn write_block(&mut self, block: &[T])
Write a full block of samples.
Sourcepub fn read_block(&self, delay: usize, output: &mut [T])
pub fn read_block(&self, delay: usize, output: &mut [T])
Read a full block starting at delay samples behind write position.
Trait Implementations§
Source§impl<T: Transcendental> Buffer<T> for TapeLoop<T>
impl<T: Transcendental> Buffer<T> for TapeLoop<T>
Source§fn as_mut_slice(&mut self) -> &mut [T]
fn as_mut_slice(&mut self) -> &mut [T]
Mutable access to the buffer data.
Source§fn copy_from(&mut self, src: &[T])
fn copy_from(&mut self, src: &[T])
Copy data from a slice. Copies
min(src.len(), self.len()) samples.Source§fn stats(&self) -> BufferStats
fn stats(&self) -> BufferStats
Snapshot of performance statistics.
Source§fn reset_stats(&mut self)
fn reset_stats(&mut self)
Reset performance counters (not the data).
Auto Trait Implementations§
impl<T> Freeze for TapeLoop<T>
impl<T> RefUnwindSafe for TapeLoop<T>where
T: RefUnwindSafe,
impl<T> Send for TapeLoop<T>where
T: Send,
impl<T> Sync for TapeLoop<T>where
T: Sync,
impl<T> Unpin for TapeLoop<T>
impl<T> UnsafeUnpin for TapeLoop<T>
impl<T> UnwindSafe for TapeLoop<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