Variable length delay-line with feedback and/or feedforward. More...
#include <Delay.h>
Public Member Functions | |
Comb () | |
Default constructor. Does not allocate memory. | |
Comb (float delay, const Tp &ffd=Tp(0), const Tp &fbk=Tp(0)) | |
Comb (float maxDelay, float delay, const Tp &ffd, const Tp &fbk) | |
void | decay (float units, float end=0.001f) |
Set number of units for response to decay to end value. | |
void | allPass (const Tp &v) |
Sets feedback to argument and feedforward to argument negated. | |
void | fbk (const Tp &v) |
Set feedback amount, in (-1, 1) | |
void | ffd (const Tp &v) |
Set feedforward amount [-1, 1]. | |
void | set (float delay, const Tp &ffd, const Tp &fbk) |
Set several parameters. | |
Tv | operator() (const Tv &i0) |
Returns next filtered value. | |
Tv | operator() (const Tv &i0, const Tv &oN) |
Circulate filter with ffd & fbk. | |
Tv | circulateFbk (const Tv &i0, const Tv &oN) |
Circulate filter with fbk only. | |
Tv | nextFbk (const Tv &i0) |
Filters sample (feedback only). | |
float | norm () const |
Get unity gain scale factor. | |
float | normFbk () const |
Get unity gain scale factor due to feedback. | |
float | normFfd () const |
Get unity gain scale factor due to feedforward. | |
Tp | ffd () const |
Get feedforward amount. | |
Tp | fbk () const |
Get feedback amount. | |
void | delay (float v) |
Set delay length. | |
float | delay () const |
Get current delay length. | |
void | delayUnit (float u) |
Set delay as (0, 1) of buffer size. | |
float | delayUnit () const |
Get unit delay (to max delay) | |
void | freq (float v) |
Set natural frequency (1/delay()) | |
float | freq () const |
Get frequency of delay line. | |
void | ipolType (ipl::Type v) |
Set interpolation type. | |
void | maxDelay (float v) |
Set maximum delay length. | |
float | maxDelay () const |
Get maximum delay length units. | |
void | zero () |
Sets all elements to zero. | |
Tv | operator() () const |
Reads delayed element from buffer. | |
Tv | read (float ago) |
Returns element 'ago' units ago. | |
void | write (const Tv &v) |
Writes element into buffer. Tap is post-incremented. | |
void | writePre (const Tv &v) |
Writes element into buffer. Tap is pre-incremented. | |
uint32_t | delayIndex (uint32_t delay) const |
Get index of delayed element. | |
uint32_t | indexBack () const |
Get index of backmost element. | |
uint32_t | fracBits () const |
Returns number of bits in fraction (32 - bits()) | |
float | fraction (uint32_t phase) const |
Get floating-point fractional part of fixed-point phase. | |
uint32_t | index (uint32_t phase) const |
Get integer part of fixed-point phase. | |
uint32_t | log2Size () const |
Returns log base-2 of the number of array elements. | |
uint32_t | oneIndex () const |
Returns 32-bit phase increment for one element index. | |
const Tv & | atPhase (uint32_t phase) const |
Get element at truncated fixed-point phase. | |
void | putPhase (uint32_t phase, Tvv) |
Set element at truncated fixed point phase. | |
Tv & | operator[] (uint32_t i) |
Get write reference to element. | |
const Tv & | operator[] (uint32_t i) const |
Get read-only reference to element. | |
ArrayBase & | assign (const Tv &v) |
Sets all elements to value. | |
ArrayBase & | assign (const Tv &v, uint32_t end, uint32_t stride=1, uint32_t start=0) |
Sets linear slice of elements to value. | |
Tv * | elems () |
Get writable pointer to elements. | |
const Tv * | elems () const |
Get read-only pointer to elements. | |
uint32_t | size () const |
Returns number of elements in array. | |
void | clear () |
Destroys all elements and frees memory. | |
void | own () |
Ensures ownership of elements. | |
bool | isSoleOwner () const |
Returns true if we are the sole owner of data internally allocated. | |
void | resize (uint32_t newSize, const Tv &c=Tv()) |
Resizes number of elements in array. | |
void | source (ArrayBase< Tv, SizeArrayPow2, gam::Allocator< Tv > > &src) |
Sets source of array elements to another array. | |
void | source (Tv *src, uint32_t size) |
Sets source of array elements to another array. | |
Static Public Member Functions | |
static int | references (Tv *m) |
Returns number of pointers to memory address being managed. |
Variable length delay-line with feedback and/or feedforward.
The general comb filter transfer function provides N evenly spaced poles and/or zeroes around the unit circle. Feedback and feedforward produce evenly spaced resonances and notches, respectively, in the frequency response. Positive feeds result in even harmonics and negative feeds give odd harmonics. If the feedback and feedforward amounts are inverses of each other, an Nth order all-pass filter results. Comb filters are stable as long as |feedback| < 1.
Tv | value type |
Si | interpolation strategy |
Tp | parameter type |
Ts | sync type |
Comb | ( | float | delay, |
const Tp & | ffd = Tp(0) , |
||
const Tp & | fbk = Tp(0) |
||
) |
[in] | delay | Delay length. The size of the delay line will be the smallest possible power of two. |
[in] | ffd | Feedforward amount, in [-1, 1] |
[in] | fbk | Feedback amount, in (-1, 1) |
Comb | ( | float | maxDelay, |
float | delay, | ||
const Tp & | ffd, | ||
const Tp & | fbk | ||
) |
[in] | maxDelay | Maximum delay length. The size of the delay line will be the smallest possible power of two. |
[in] | delay | Delay length |
[in] | ffd | Feedforward amount, in [-1, 1] |
[in] | fbk | Feedback amount, in (-1, 1) |
ArrayBase& assign | ( | const Tv & | v, |
uint32_t | end, | ||
uint32_t | stride = 1 , |
||
uint32_t | start = 0 |
||
) | [inherited] |
Sets linear slice of elements to value.
[in] | v | value to be copied as new content |
[in] | end | end index (exclusive) |
[in] | stride | index stride amount |
[in] | start | start index (inclusive) |
void decay | ( | float | units, |
float | end = 0.001f |
||
) |
Set number of units for response to decay to end value.
The sign of the decay length determines the sign of the feedback coefficient. The default end value of 0.001 (-60 dB) is the reverberation time of the filter. Setting the decay amount effects only the feedback value. The decay must be updated whenever the delay length of the filter changes.
void own | ( | ) | [inherited] |
Ensures ownership of elements.
If the array is not already the sole owner, new memory is allocated and the previously referenced array elements are copied.
void resize | ( | uint32_t | newSize, |
const Tv & | c = T() |
||
) | [inherited] |
Resizes number of elements in array.
If the new size is less than the old size, then elements are truncated. If the new size is greater than the old size, then the argument value is copied into the additional elements.