30template <
typename SampleType,
typename InterpolationType>
36template <
typename SampleType,
typename InterpolationType>
39 jassert (maximumDelayInSamples >= 0);
43 setMaximumDelayInSamples (maximumDelayInSamples);
47template <
typename SampleType,
typename InterpolationType>
50 auto upperLimit = (SampleType) getMaximumDelayInSamples();
53 delay =
jlimit ((SampleType) 0, upperLimit, newDelayInSamples);
54 delayInt =
static_cast<int> (
std::floor (delay));
55 delayFrac = delay - (SampleType) delayInt;
57 updateInternalVariables();
60template <
typename SampleType,
typename InterpolationType>
67template <
typename SampleType,
typename InterpolationType>
72 bufferData.setSize ((
int) spec.
numChannels, totalSize,
false,
false,
true);
83template <
typename SampleType,
typename InterpolationType>
86 jassert (maxDelayInSamples >= 0);
87 totalSize =
jmax (4, maxDelayInSamples + 2);
88 bufferData.setSize ((
int) bufferData.getNumChannels(), totalSize,
false,
false,
true);
92template <
typename SampleType,
typename InterpolationType>
95 for (
auto vec : { &writePos, &readPos })
98 std::fill (v.begin(), v.end(),
static_cast<SampleType
> (0));
104template <
typename SampleType,
typename InterpolationType>
107 bufferData.setSample (channel, writePos[(
size_t) channel], sample);
108 writePos[(
size_t) channel] = (writePos[(
size_t) channel] + totalSize - 1) % totalSize;
111template <
typename SampleType,
typename InterpolationType>
114 if (delayInSamples >= 0)
115 setDelay (delayInSamples);
117 auto result = interpolateSample (channel);
119 if (updateReadPointer)
120 readPos[(
size_t) channel] = (readPos[(
size_t) channel] + totalSize - 1) % totalSize;
A delay line processor featuring several algorithms for the fractional delay calculation,...
void prepare(const ProcessSpec &spec)
Initialises the processor.
void setDelay(SampleType newDelayInSamples)
Sets the delay in samples.
SampleType popSample(int channel, SampleType delayInSamples=-1, bool updateReadPointer=true)
Pops a single sample from one channel of the delay line.
DelayLine()
Default constructor.
void setMaximumDelayInSamples(int maxDelayInSamples)
Sets a new maximum delay in samples.
SampleType getDelay() const
Returns the current delay in samples.
void reset()
Resets the internal state variables of the processor.
void pushSample(int channel, SampleType sample)
Pushes a single sample into one channel of the delay line.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
bool isPositiveAndNotGreaterThan(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also less than or equal to a specified upper limit.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
uint32 numChannels
The number of channels that the process() method will be expected to handle.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.