A fractional delay line implementation, with configurable interpolation types.
More...
#include <marvin_DelayLine.h>
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.
◆ DelayLine() [1/2]
◆ DelayLine() [2/2]
Constructs a DelayLine, and initialises maximumDelayInSamples
.
- Parameters
-
maximumDelayInSamples | The max size of the internal buffer. |
◆ getDelay()
Returns the currently set delay time.
- Returns
- The delay time, in samples.
◆ getMaximumDelayInSamples()
Returns the maximum length of the internal buffer.
- Returns
- The maximum delay in samples.
◆ getReadPos()
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()
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()
Initialises the delay line. Make sure to call this function before any audio calls!
- Parameters
-
sampleRate | The sample rate the DelayLine should run at. |
◆ popSample()
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
-
delayInSamples | An optional offset from writePos to read from. |
updateReadPointer | Whether 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()
Pushes a sample into the DelayLine.
- Parameters
-
◆ reset()
Clears the internal buffer, and resets the DelayLine to its initialised state.
◆ setDelay()
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
-
newDelayInSamples | The new delay to use, in samples. |
◆ setMaximumDelayInSamples()
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
-
maxDelayInSamples | The amount of samples to allocate in the buffer. |
The documentation for this class was generated from the following file:
- /home/runner/work/mostly-harmless/mostly-harmless/modules/marvin/include/marvin/dsp/marvin_DelayLine.h