| 1 |
/***************************************************/ |
| 2 |
/*! \class DelayL |
| 3 |
\brief STK linear interpolating delay line class. |
| 4 |
|
| 5 |
This Delay subclass implements a fractional- |
| 6 |
length digital delay-line using first-order |
| 7 |
linear interpolation. A fixed maximum length |
| 8 |
of 4095 and a delay of zero is set using the |
| 9 |
default constructor. Alternatively, the |
| 10 |
delay and maximum length can be set during |
| 11 |
instantiation with an overloaded constructor. |
| 12 |
|
| 13 |
Linear interpolation is an efficient technique |
| 14 |
for achieving fractional delay lengths, though |
| 15 |
it does introduce high-frequency signal |
| 16 |
attenuation to varying degrees depending on the |
| 17 |
fractional delay setting. The use of higher |
| 18 |
order Lagrange interpolators can typically |
| 19 |
improve (minimize) this attenuation characteristic. |
| 20 |
|
| 21 |
by Perry R. Cook and Gary P. Scavone, 1995 - 2005. |
| 22 |
*/ |
| 23 |
/***************************************************/ |
| 24 |
|
| 25 |
#ifndef STK_DELAYL_H |
| 26 |
#define STK_DELAYL_H |
| 27 |
|
| 28 |
#include "Delay.h" |
| 29 |
|
| 30 |
namespace Nyq |
| 31 |
{ |
| 32 |
|
| 33 |
class DelayL : public Delay |
| 34 |
{ |
| 35 |
public: |
| 36 |
|
| 37 |
//! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay. |
| 38 |
DelayL(); |
| 39 |
|
| 40 |
//! Overloaded constructor which specifies the current and maximum delay-line lengths. |
| 41 |
/*! |
| 42 |
An StkError will be thrown if the delay parameter is less than |
| 43 |
zero, the maximum delay parameter is less than one, or the delay |
| 44 |
parameter is greater than the maxDelay value. |
| 45 |
*/ |
| 46 |
DelayL(StkFloat delay, unsigned long maxDelay); |
| 47 |
|
| 48 |
//! Class destructor. |
| 49 |
~DelayL(); |
| 50 |
|
| 51 |
//! Set the delay-line length. |
| 52 |
/*! |
| 53 |
The valid range for \e theDelay is from 0 to the maximum delay-line length. |
| 54 |
*/ |
| 55 |
void setDelay(StkFloat delay); |
| 56 |
|
| 57 |
//! Return the current delay-line length. |
| 58 |
StkFloat getDelay(void) const; |
| 59 |
|
| 60 |
//! Return the value which will be output by the next call to tick(). |
| 61 |
/*! |
| 62 |
This method is valid only for delay settings greater than zero! |
| 63 |
*/ |
| 64 |
StkFloat nextOut(void); |
| 65 |
|
| 66 |
protected: |
| 67 |
|
| 68 |
StkFloat computeSample( StkFloat input ); |
| 69 |
|
| 70 |
StkFloat alpha_; |
| 71 |
StkFloat omAlpha_; |
| 72 |
StkFloat nextOutput_; |
| 73 |
bool doNextOut_; |
| 74 |
}; |
| 75 |
|
| 76 |
} // namespace Nyq |
| 77 |
|
| 78 |
#endif |