JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::dsp::DelayLine< SampleType, InterpolationType > Class Template Reference

A delay line processor featuring several algorithms for the fractional delay calculation, block processing, and sample-by-sample processing useful when modulating the delay in real time or creating a standard delay effect with feedback. More...

#include <juce_DelayLine.h>

Inheritance diagram for juce::dsp::DelayLine< SampleType, InterpolationType >:
Collaboration diagram for juce::dsp::DelayLine< SampleType, InterpolationType >:

Public Member Functions

 DelayLine ()
 Default constructor. More...
 
 DelayLine (int maximumDelayInSamples)
 Constructor. More...
 
SampleType getDelay () const
 Returns the current delay in samples. More...
 
int getMaximumDelayInSamples () const noexcept
 Gets the maximum possible delay in samples. More...
 
SampleType popSample (int channel, SampleType delayInSamples=-1, bool updateReadPointer=true)
 Pops a single sample from one channel of the delay line. More...
 
void prepare (const ProcessSpec &spec)
 Initialises the processor. More...
 
template<typename ProcessContext >
void process (const ProcessContext &context) noexcept
 Processes the input and output samples supplied in the processing context. More...
 
void pushSample (int channel, SampleType sample)
 Pushes a single sample into one channel of the delay line. More...
 
void reset ()
 Resets the internal state variables of the processor. More...
 
void setDelay (SampleType newDelayInSamples)
 Sets the delay in samples. More...
 
void setMaximumDelayInSamples (int maxDelayInSamples)
 Sets a new maximum delay in samples. More...
 

Private Member Functions

template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::Thiran >::value, SampleType >::type interpolateSample (int channel)
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::None >::value, SampleType >::type interpolateSample (int channel) const
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::Linear >::value, SampleType >::type interpolateSample (int channel) const
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::Lagrange3rd >::value, SampleType >::type interpolateSample (int channel) const
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::None >::value, void >::type updateInternalVariables ()
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::Linear >::value, void >::type updateInternalVariables ()
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::Lagrange3rd >::value, void >::type updateInternalVariables ()
 
template<typename T = InterpolationType>
std::enable_if< std::is_same< T, DelayLineInterpolationTypes::Thiran >::value, void >::type updateInternalVariables ()
 

Private Attributes

SampleType alpha = 0.0
 
AudioBuffer< SampleType > bufferData
 
SampleType delay = 0.0
 
SampleType delayFrac = 0.0
 
int delayInt = 0
 
std::vector< intreadPos
 
double sampleRate
 
int totalSize = 4
 
std::vector< SampleType > v
 
std::vector< intwritePos
 

Detailed Description

template<typename SampleType, typename InterpolationType = DelayLineInterpolationTypes::Linear>
class juce::dsp::DelayLine< SampleType, InterpolationType >

A delay line processor featuring several algorithms for the fractional delay calculation, block processing, and sample-by-sample processing useful when modulating the delay in real time or creating a standard delay effect with feedback.

Note: If you intend to change the delay in real time, you may want to smooth changes to the delay systematically using either a ramp or a low-pass filter.

See also
SmoothedValue, FirstOrderTPTFilter

@tags{DSP}

Constructor & Destructor Documentation

◆ DelayLine() [1/2]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
juce::dsp::DelayLine< SampleType, InterpolationType >::DelayLine ( )

Default constructor.

◆ DelayLine() [2/2]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
juce::dsp::DelayLine< SampleType, InterpolationType >::DelayLine ( int  maximumDelayInSamples)
explicit

Constructor.

Member Function Documentation

◆ getDelay()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
SampleType juce::dsp::DelayLine< SampleType, InterpolationType >::getDelay ( ) const

Returns the current delay in samples.

◆ getMaximumDelayInSamples()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
int juce::dsp::DelayLine< SampleType, InterpolationType >::getMaximumDelayInSamples ( ) const
inlinenoexcept

Gets the maximum possible delay in samples.

For very short delay times, the result of getMaximumDelayInSamples() may differ from the last value passed to setMaximumDelayInSamples().

◆ interpolateSample() [1/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::Thiran>::value, SampleType>::type juce::dsp::DelayLine< SampleType, InterpolationType >::interpolateSample ( int  channel)
inlineprivate

◆ interpolateSample() [2/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::None>::value, SampleType>::type juce::dsp::DelayLine< SampleType, InterpolationType >::interpolateSample ( int  channel) const
inlineprivate

◆ interpolateSample() [3/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::Linear>::value, SampleType>::type juce::dsp::DelayLine< SampleType, InterpolationType >::interpolateSample ( int  channel) const
inlineprivate

◆ interpolateSample() [4/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::Lagrange3rd>::value, SampleType>::type juce::dsp::DelayLine< SampleType, InterpolationType >::interpolateSample ( int  channel) const
inlineprivate

◆ popSample()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
SampleType juce::dsp::DelayLine< SampleType, InterpolationType >::popSample ( int  channel,
SampleType  delayInSamples = -1,
bool  updateReadPointer = true 
)

Pops a single sample from one channel of the delay line.

Use this function to modulate the delay in real time or implement standard delay effects with feedback.

Parameters
channelthe target channel for the delay line.
delayInSamplessets the wanted fractional delay in samples, or -1 to use the value being used before or set with setDelay function.
updateReadPointershould be set to true if you use the function once for each sample, or false if you need multi-tap delay capabilities.
See also
setDelay, pushSample, process

Referenced by juce::dsp::DelayLine< SampleType, juce::dsp::DelayLineInterpolationTypes::Thiran >::process().

◆ prepare()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
void juce::dsp::DelayLine< SampleType, InterpolationType >::prepare ( const ProcessSpec spec)

Initialises the processor.

◆ process()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename ProcessContext >
void juce::dsp::DelayLine< SampleType, InterpolationType >::process ( const ProcessContext context)
inlinenoexcept

Processes the input and output samples supplied in the processing context.

Can be used for block processing when the delay is not going to change during processing. The delay must first be set by calling setDelay.

See also
setDelay

◆ pushSample()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
void juce::dsp::DelayLine< SampleType, InterpolationType >::pushSample ( int  channel,
SampleType  sample 
)

Pushes a single sample into one channel of the delay line.

Use this function and popSample instead of process if you need to modulate the delay in real time instead of using a fixed delay value, or if you want to code a delay effect with a feedback loop.

See also
setDelay, popSample, process

Referenced by juce::dsp::DelayLine< SampleType, juce::dsp::DelayLineInterpolationTypes::Thiran >::process().

◆ reset()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
void juce::dsp::DelayLine< SampleType, InterpolationType >::reset ( )

Resets the internal state variables of the processor.

◆ setDelay()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
void juce::dsp::DelayLine< SampleType, InterpolationType >::setDelay ( SampleType  newDelayInSamples)

Sets the delay in samples.

◆ setMaximumDelayInSamples()

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
void juce::dsp::DelayLine< SampleType, InterpolationType >::setMaximumDelayInSamples ( int  maxDelayInSamples)

Sets a new maximum delay in samples.

Also clears the delay line.

This may allocate internally, so you should never call it from the audio thread.

◆ updateInternalVariables() [1/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::None>::value, void>::type juce::dsp::DelayLine< SampleType, InterpolationType >::updateInternalVariables ( )
inlineprivate

◆ updateInternalVariables() [2/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::Linear>::value, void>::type juce::dsp::DelayLine< SampleType, InterpolationType >::updateInternalVariables ( )
inlineprivate

◆ updateInternalVariables() [3/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::Lagrange3rd>::value, void>::type juce::dsp::DelayLine< SampleType, InterpolationType >::updateInternalVariables ( )
inlineprivate

◆ updateInternalVariables() [4/4]

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
template<typename T = InterpolationType>
std::enable_if<std::is_same <T, DelayLineInterpolationTypes::Thiran>::value, void>::type juce::dsp::DelayLine< SampleType, InterpolationType >::updateInternalVariables ( )
inlineprivate

Member Data Documentation

◆ alpha

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
SampleType juce::dsp::DelayLine< SampleType, InterpolationType >::alpha = 0.0
private

◆ bufferData

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
AudioBuffer<SampleType> juce::dsp::DelayLine< SampleType, InterpolationType >::bufferData
private

◆ delay

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
SampleType juce::dsp::DelayLine< SampleType, InterpolationType >::delay = 0.0
private

◆ delayFrac

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
SampleType juce::dsp::DelayLine< SampleType, InterpolationType >::delayFrac = 0.0
private

◆ delayInt

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
int juce::dsp::DelayLine< SampleType, InterpolationType >::delayInt = 0
private

◆ readPos

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
std::vector<int> juce::dsp::DelayLine< SampleType, InterpolationType >::readPos
private

◆ sampleRate

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
double juce::dsp::DelayLine< SampleType, InterpolationType >::sampleRate
private

◆ totalSize

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
int juce::dsp::DelayLine< SampleType, InterpolationType >::totalSize = 4
private

◆ v

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
std::vector<SampleType> juce::dsp::DelayLine< SampleType, InterpolationType >::v
private

◆ writePos

template<typename SampleType , typename InterpolationType = DelayLineInterpolationTypes::Linear>
std::vector<int> juce::dsp::DelayLine< SampleType, InterpolationType >::writePos
private

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