pub struct RingBuffer<T, const N: usize>where
T: Transcendental,{ /* private fields */ }Expand description
Fixed-size ring buffer (power-of-two size). Single-threaded.
Used inside the signal graph for delay effects and sample buffering. Size must be a power of two.
§Example
use rill_core::buffer::RingBuffer;
let mut buffer = RingBuffer::<f32, 4>::new();
buffer.write(1.0);
buffer.write(2.0);
assert_eq!(buffer.read_delayed(0), 2.0);Implementations§
Source§impl<T, const N: usize> RingBuffer<T, N>where
T: Transcendental,
impl<T, const N: usize> RingBuffer<T, N>where
T: Transcendental,
Sourcepub fn new() -> RingBuffer<T, N>
pub fn new() -> RingBuffer<T, N>
Sourcepub fn write_slice(&mut self, samples: &[T])where
T: Copy,
pub fn write_slice(&mut self, samples: &[T])where
T: Copy,
Write multiple samples in sequence.
Sourcepub fn read_delayed(&self, delay: usize) -> T
pub fn read_delayed(&self, delay: usize) -> T
Sourcepub fn read_interpolated(&self, delay_frac: f32) -> T
pub fn read_interpolated(&self, delay_frac: f32) -> T
Read with linear interpolation between samples at fractional delay.
Sourcepub fn read_sequence_interpolated(&self, start_delay: f32, output: &mut [T])
pub fn read_sequence_interpolated(&self, start_delay: f32, output: &mut [T])
Read a sequence of interpolated samples into the output buffer,
starting at start_delay samples behind head.
Source§impl<T, const N: usize> RingBuffer<T, N>where
T: Transcendental,
impl<T, const N: usize> RingBuffer<T, N>where
T: Transcendental,
Trait Implementations§
Source§impl<T, const N: usize> Buffer<T> for RingBuffer<T, N>where
T: Transcendental,
impl<T, const N: usize> Buffer<T> for RingBuffer<T, N>where
T: Transcendental,
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).
Source§impl<T, const N: usize> Debug for RingBuffer<T, N>where
T: Transcendental + Debug,
impl<T, const N: usize> Debug for RingBuffer<T, N>where
T: Transcendental + Debug,
Source§impl<T, const N: usize> Default for RingBuffer<T, N>where
T: Transcendental,
impl<T, const N: usize> Default for RingBuffer<T, N>where
T: Transcendental,
Source§fn default() -> RingBuffer<T, N>
fn default() -> RingBuffer<T, N>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<T, const N: usize> Freeze for RingBuffer<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for RingBuffer<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for RingBuffer<T, N>
impl<T, const N: usize> Sync for RingBuffer<T, N>
impl<T, const N: usize> Unpin for RingBuffer<T, N>where
T: Unpin,
impl<T, const N: usize> UnsafeUnpin for RingBuffer<T, N>where
T: UnsafeUnpin,
impl<T, const N: usize> UnwindSafe for RingBuffer<T, N>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