Skip to main content

DelayLine

Struct DelayLine 

Source
pub struct DelayLine<T: Transcendental, const MAX_DELAY: usize> { /* private fields */ }
Expand description

Delay line for audio effects

Provides a circular buffer for implementing delay, reverb, and other time-based effects.

Implementations§

Source§

impl<T: Transcendental, const MAX_DELAY: usize> DelayLine<T, MAX_DELAY>

Source

pub fn new(sample_rate: f32) -> Self

Create a new delay line with the specified sample rate

§Arguments
  • sample_rate - Sample rate in Hz (e.g., 44100.0)
§Panics

Panics if MAX_DELAY is 0.

Source

pub fn set_delay(&mut self, delay_sec: f32)

Set delay time in seconds

Source

pub fn set_delay_samples(&mut self, samples: usize)

Set delay in samples

Source

pub fn delay_samples(&self) -> usize

Get current delay in samples

Source

pub const fn max_delay(&self) -> usize

Get maximum possible delay in samples

Source

pub fn sample_rate(&self) -> f32

Get the current sample rate

Source

pub fn write(&mut self, input: T) -> T

Write a sample and return the delayed sample

Source

pub fn read(&self) -> T

Read the delayed sample without writing

Source

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

Read sample at arbitrary delay (0 = most recent)

Source

pub fn read_interpolated(&self, delay_frac: f32) -> T

Read with linear interpolation between samples

Source

pub fn clear(&mut self)

Clear the delay line (fill with zeros)

Source

pub fn write_position(&self) -> usize

Get current write position

Trait Implementations§

Source§

impl<T: Transcendental, const MAX_DELAY: usize> Index<usize> for DelayLine<T, MAX_DELAY>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, _index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Transcendental, const MAX_DELAY: usize> IndexMut<usize> for DelayLine<T, MAX_DELAY>

Source§

fn index_mut(&mut self, _index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: Transcendental, const MAX_DELAY: usize> SignalBuffer<T> for DelayLine<T, MAX_DELAY>

Source§

fn capacity(&self) -> usize

Get the total capacity of the buffer in samples Read more
Source§

fn len(&self) -> usize

Get the current number of items in the buffer Read more
Source§

fn is_empty(&self) -> bool

Check if the buffer is empty
Source§

fn is_full(&self) -> bool

Check if the buffer is full
Source§

fn clear(&mut self)

Clear all items from the buffer Read more
Source§

fn stats(&self) -> BufferStats

Get a snapshot of current buffer statistics
Source§

fn reset_stats(&mut self)

Reset all statistics to zero Read more

Auto Trait Implementations§

§

impl<T, const MAX_DELAY: usize> !Freeze for DelayLine<T, MAX_DELAY>

§

impl<T, const MAX_DELAY: usize> !RefUnwindSafe for DelayLine<T, MAX_DELAY>

§

impl<T, const MAX_DELAY: usize> Send for DelayLine<T, MAX_DELAY>

§

impl<T, const MAX_DELAY: usize> Sync for DelayLine<T, MAX_DELAY>

§

impl<T, const MAX_DELAY: usize> Unpin for DelayLine<T, MAX_DELAY>
where T: Unpin,

§

impl<T, const MAX_DELAY: usize> UnsafeUnpin for DelayLine<T, MAX_DELAY>
where T: UnsafeUnpin,

§

impl<T, const MAX_DELAY: usize> UnwindSafe for DelayLine<T, MAX_DELAY>
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.