Skip to main content

RingQueue

Struct RingQueue 

Source
pub struct RingQueue<T: Copy, const CAP: usize> { /* private fields */ }
Expand description

Ring queue with random access

Allows reading data not only from the head, but also with arbitrary delay. Useful for delay effects and reverb.

Implementations§

Source§

impl<T: Copy + Default, const CAP: usize> RingQueue<T, CAP>

Source

pub fn new() -> Self

Create a new ring queue

Source

pub fn push(&self, value: T)

Push an element (always succeeds)

Source

pub fn read_delayed(&self, delay: usize) -> T

Read an element with delay

§Arguments
  • delay - delay in samples (0 = most recently written)
Source

pub fn read_interpolated(&self, delay_frac: f64) -> T
where T: From<f64> + Into<f64>,

Read an element with fractional delay (linear interpolation)

Source

pub fn read_at(&self, index: usize) -> T

Read an element by absolute index

Source

pub fn push_slice(&self, slice: &[T])

Push a slice of data

Source

pub fn read_slice_delayed(&self, delay: usize, output: &mut [T])

Read a slice of data with delay

Source

pub fn write_pos(&self) -> usize

Current write position

Source

pub const fn capacity(&self) -> usize

Capacity

Source

pub fn len(&self) -> usize

Number of written elements (no more than CAP)

Source

pub fn is_empty(&self) -> bool

Returns true if no elements have been written.

Source

pub fn reset(&self)

Reset the write position

Source

pub fn stats(&self) -> &QueueStats

Get statistics

Trait Implementations§

Source§

impl<T: Copy + Default, const CAP: usize> Default for RingQueue<T, CAP>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Copy + Send, const CAP: usize> Send for RingQueue<T, CAP>

Source§

impl<T: Copy + Sync, const CAP: usize> Sync for RingQueue<T, CAP>

Auto Trait Implementations§

§

impl<T, const CAP: usize> !Freeze for RingQueue<T, CAP>

§

impl<T, const CAP: usize> !RefUnwindSafe for RingQueue<T, CAP>

§

impl<T, const CAP: usize> Unpin for RingQueue<T, CAP>
where T: Unpin,

§

impl<T, const CAP: usize> UnsafeUnpin for RingQueue<T, CAP>
where T: UnsafeUnpin,

§

impl<T, const CAP: usize> UnwindSafe for RingQueue<T, CAP>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V