25 DelayLine(
float maxDelayTime,
float fs,
unsigned int nTaps = 1);
31 int setup(
float maxDelayTime,
float fs,
unsigned int nTaps);
42 float process(
float input);
49 void setDelayTime(
float delayTime,
unsigned int tap = 0)
51 tap = this->constrain<unsigned int>(tap, 0, _nTaps-1);
52 _delaySamples[tap] = this->constrain<float>(_fs * delayTime / 1000.0, 0.0, (float)(_delayBuffer.size()));
59 float getDelayTime(
unsigned int tap = 0) {
return 1000.0 *_delaySamples[tap] / _fs; };
62 void setFeedbackGain(
float feedbackGain)
64 _feedbackGain = this->constrain<float>(feedbackGain, 0.0, 0.99);
67 float getFeedbackGain(){
return _feedbackGain; };
70 void setDryLevel(
float dryLevel)
72 _dryLevel = this->constrain<float>(dryLevel, 0.0, 1.0);
75 float getDryLevel(){
return _dryLevel; };
78 void setWetLevel(
float wetLevel)
80 _wetLevel = this->constrain<float>(wetLevel, 0.0, 1.0);
83 float getWetLevel(){
return _wetLevel; };
89 void setWetDryMix(
float wetDryMix)
91 _wetLevel = this->constrain<float>(wetDryMix, 0.0, 1.0);
92 _dryLevel = 1.0 - _wetLevel;
103 template <
typename T>
104 static T constrain(T val, T
min, T
max)
122 static float lerp(
float index,
float pVal,
float nVal);
126 float getFeedbackSend() {
return _feedbackSend; };
134 void setFeedbackReturn(
float feedbackReturn,
bool preGain =
false)
136 _feedbackReturn = (preGain) ? feedbackReturn : _feedbackGain * feedbackReturn;
143 void useExternalFeedback(
bool doUse) { _externalFeedback = doUse; }
150 float getTapOutput(
unsigned int tap,
bool preGain =
true)
152 updateReadPointer(tap);
153 return (preGain) ? interpolatedRead(_readPtr[tap]) : interpolatedRead(_readPtr[tap] * _wetLevel);
160 void useSeparateTaps(
bool doUse) { _separateTaps = doUse; };
162 void flush() { std::fill(_delayBuffer.begin(), _delayBuffer.end(), 0); }
166 for(
unsigned int t = 1; t<_nTaps; t++)
168 _delaySamples[t] = _delaySamples[0];
169 _readPtr[t] = _readPtr[0];
175 float * _delaySamples =
nullptr;
176 float _feedbackGain = 0.0;
177 float _dryLevel = 1.0;
178 float _wetLevel = 0.0;
180 float _feedbackSend = 0.0;
181 float _feedbackReturn = 0.0;
182 bool _externalFeedback =
false;
184 unsigned int _writePtr = 0;
186 unsigned int _nTaps = 1;
187 float *_readPtr =
nullptr;
188 bool _separateTaps =
false;
190 std::vector<float> _delayBuffer;
195 void updateWritePointer()
197 if(++_writePtr >= _delayBuffer.size())
204 void updateReadPointer(
unsigned int tap = 0);
208 float interpolatedRead(
float index);
static float min(float x, float y)
Returns the maximum of two numbers.
Definition: Utilities.h:92
static float max(float x, float y)
Returns the minimum of two numbers.
Definition: Utilities.h:88
Definition: DelayLine.h:13