Skip to main content

RingQueue

Struct RingQueue 

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

Кольцевая очередь с произвольным доступом

Позволяет читать данные не только из головы, но и с произвольной задержкой. Полезно для эффектов задержки и реверберации.

Implementations§

Source§

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

Source

pub fn new() -> Self

Создать новую кольцевую очередь

Source

pub fn push(&self, value: T)

Записать элемент (всегда успешно)

Source

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

Прочитать элемент с задержкой

§Arguments
  • delay - задержка в семплах (0 = последний записанный)
Source

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

Прочитать элемент с плавающей задержкой (линейная интерполяция)

Source

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

Прочитать элемент по абсолютному индексу

Source

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

Записать массив данных

Source

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

Прочитать срез данных с задержкой

Source

pub fn write_pos(&self) -> usize

Текущая позиция записи

Source

pub const fn capacity(&self) -> usize

Ёмкость

Source

pub fn len(&self) -> usize

Количество записанных элементов (не больше CAP)

Source

pub fn reset(&self)

Сбросить позицию записи

Source

pub fn stats(&self) -> &QueueStats

Получить статистику

Trait Implementations§

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.