Struct DelayBuffer

Source
pub struct DelayBuffer<F: Flt> { /* private fields */ }
Expand description

This is a delay buffer/line with linear and cubic interpolation.

It’s the basic building block underneath the all-pass filter, comb filters and delay effects. You can use linear and cubic and no interpolation to access samples in the past. Either by sample offset or time (millisecond) based.

Implementations§

Source§

impl<F: Flt> DelayBuffer<F>

Source

pub fn new() -> Self

Creates a delay buffer with about 5 seconds of capacity at 8*48000Hz sample rate.

Source

pub fn new_with_size(size: usize) -> Self

Creates a delay buffer with the given amount of samples capacity.

Source

pub fn set_sample_rate(&mut self, srate: F)

Sets the sample rate that is used for milliseconds => sample conversion.

Source

pub fn reset(&mut self)

Reset the delay buffer contents and write position.

Source

pub fn feed(&mut self, input: F)

Feed one sample into the delay line and increment the write pointer. Please note: For sample accurate feedback you need to retrieve the output of the delay line before feeding in a new signal.

Source

pub fn next_cubic(&mut self, delay_time_ms: F, input: F) -> F

Combines DelayBuffer::cubic_interpolate_at and DelayBuffer::feed into one convenient function.

Source

pub fn next_linear(&mut self, delay_time_ms: F, input: F) -> F

Combines DelayBuffer::linear_interpolate_at and DelayBuffer::feed into one convenient function.

Source

pub fn next_nearest(&mut self, delay_time_ms: F, input: F) -> F

Combines DelayBuffer::nearest_at and DelayBuffer::feed into one convenient function.

Source

pub fn tap_c(&self, delay_time_ms: F) -> F

Source

pub fn tap_n(&self, delay_time_ms: F) -> F

Source

pub fn tap_l(&self, delay_time_ms: F) -> F

Source

pub fn linear_interpolate_at(&self, delay_time_ms: F) -> F

Fetch a sample from the delay buffer at the given tim with linear interpolation.

  • delay_time_ms - Delay time in milliseconds.
Source

pub fn linear_interpolate_at_s(&self, s_offs: F) -> F

Fetch a sample from the delay buffer at the given offset with linear interpolation.

  • s_offs - Sample offset in samples.
Source

pub fn cubic_interpolate_at(&self, delay_time_ms: F) -> F

Fetch a sample from the delay buffer at the given time with cubic interpolation.

  • delay_time_ms - Delay time in milliseconds.
Source

pub fn cubic_interpolate_at_s(&self, s_offs: F) -> F

Fetch a sample from the delay buffer at the given offset with cubic interpolation.

  • s_offs - Sample offset in samples into the past of the DelayBuffer from the current write (or the “now”) position.
Source

pub fn nearest_at(&self, delay_time_ms: F) -> F

Fetch a sample from the delay buffer at the given time without any interpolation.

  • delay_time_ms - Delay time in milliseconds.
Source

pub fn at(&self, delay_sample_count: usize) -> F

Fetch a sample from the delay buffer at the given number of samples in the past.

Trait Implementations§

Source§

impl<F: Clone + Flt> Clone for DelayBuffer<F>

Source§

fn clone(&self) -> DelayBuffer<F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + Flt> Debug for DelayBuffer<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: Default + Flt> Default for DelayBuffer<F>

Source§

fn default() -> DelayBuffer<F>

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

Auto Trait Implementations§

§

impl<F> Freeze for DelayBuffer<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for DelayBuffer<F>
where F: RefUnwindSafe,

§

impl<F> Send for DelayBuffer<F>
where F: Send,

§

impl<F> Sync for DelayBuffer<F>
where F: Sync,

§

impl<F> Unpin for DelayBuffer<F>
where F: Unpin,

§

impl<F> UnwindSafe for DelayBuffer<F>
where F: 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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.