MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin::dsp::DelayLine< SampleType, InterpolationType > Class Template Reference

A fractional delay line implementation, with configurable interpolation types. More...

#include <marvin_DelayLine.h>

Public Member Functions

 DelayLine ()
 
 DelayLine (int maximumDelayInSamples)
 
void setDelay (SampleType newDelayInSamples)
 
SampleType getDelay () const noexcept
 
void initialise (double sampleRate)
 
void setMaximumDelayInSamples (int maxDelayInSamples)
 
int getMaximumDelayInSamples () const noexcept
 
void reset ()
 
void pushSample (SampleType sample)
 
SampleType popSample (SampleType delayInSamples=-1, bool updateReadPointer=true)
 
int getReadPos () const noexcept
 
int getWritePos () const noexcept
 

Detailed Description

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
class marvin::dsp::DelayLine< SampleType, InterpolationType >

A fractional delay line implementation, with configurable interpolation types.

For available options for interpolation, see the marvin::dsp::DelayLineInterpolationType enum class.

Constructor & Destructor Documentation

◆ DelayLine() [1/2]

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
marvin::dsp::DelayLine< SampleType, InterpolationType >::DelayLine ( )

Constructs a DelayLine without initialising the maximumDelayInSamples - make sure to call setMaximumDelayInSamples() before trying to use it!

◆ DelayLine() [2/2]

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
marvin::dsp::DelayLine< SampleType, InterpolationType >::DelayLine ( int maximumDelayInSamples)
explicit

Constructs a DelayLine, and initialises maximumDelayInSamples.

Parameters
maximumDelayInSamplesThe max size of the internal buffer.

Member Function Documentation

◆ getDelay()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
SampleType marvin::dsp::DelayLine< SampleType, InterpolationType >::getDelay ( ) const
nodiscardnoexcept

Returns the currently set delay time.

Returns
The delay time, in samples.

◆ getMaximumDelayInSamples()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
int marvin::dsp::DelayLine< SampleType, InterpolationType >::getMaximumDelayInSamples ( ) const
nodiscardnoexcept

Returns the maximum length of the internal buffer.

Returns
The maximum delay in samples.

◆ getReadPos()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
int marvin::dsp::DelayLine< SampleType, InterpolationType >::getReadPos ( ) const
nodiscardnoexcept

Retrieves the current position of the read head. Note that the read head runs backwards (ie towards zero).

Returns
The current position of the read head.

◆ getWritePos()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
int marvin::dsp::DelayLine< SampleType, InterpolationType >::getWritePos ( ) const
nodiscardnoexcept

Retrives the current position of the write head. Note that the write head runs backwards (ie towards zero).

Returns
The current position of the write head.

◆ initialise()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
void marvin::dsp::DelayLine< SampleType, InterpolationType >::initialise ( double sampleRate)

Initialises the delay line. Make sure to call this function before any audio calls!

Parameters
sampleRateThe sample rate the DelayLine should run at.

◆ popSample()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
SampleType marvin::dsp::DelayLine< SampleType, InterpolationType >::popSample ( SampleType delayInSamples = -1,
bool updateReadPointer = true )
nodiscard

Returns the sample at the internal readPos dictated by the earlier calls to setDelay if delayInSamples is -1, or the sample at writePos + delayInSamples if it isn't. If updateReadPointer is false, the internal read pointer does not update, which is useful for a multitap configuration.

Parameters
delayInSamplesAn optional offset from writePos to read from.
updateReadPointerWhether or not the internal read pointer should advance its position.
Returns
The sample at the internal readPos if delayInSamples == -1, the sample at writePos + delayInSamples otherwise.

◆ pushSample()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
void marvin::dsp::DelayLine< SampleType, InterpolationType >::pushSample ( SampleType sample)

Pushes a sample into the DelayLine.

Parameters
sampleThe sample to add to the DelayLine.

◆ reset()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
void marvin::dsp::DelayLine< SampleType, InterpolationType >::reset ( )

Clears the internal buffer, and resets the DelayLine to its initialised state.

◆ setDelay()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
void marvin::dsp::DelayLine< SampleType, InterpolationType >::setDelay ( SampleType newDelayInSamples)

Sets the delay time (in samples) to newDelayInSamples. Clamps to be in the range 0 to maximumDelayInSamples. Note that the internal delay variable this sets is not atomic, so ensure that this function is either called on the audio-thread, or called when the audio-thread is not running.

Parameters
newDelayInSamplesThe new delay to use, in samples.

◆ setMaximumDelayInSamples()

template<FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
void marvin::dsp::DelayLine< SampleType, InterpolationType >::setMaximumDelayInSamples ( int maxDelayInSamples)

Sets the maximum length of the internal buffer. Will allocate if more space is required by the internal vector, so it's best to call this from the parent's initialise() function before any processing, with the max length the delay line will ever be.

Parameters
maxDelayInSamplesThe amount of samples to allocate in the buffer.

The documentation for this class was generated from the following file: