27template <
typename T,
size_t max_size>
40 for(
size_t i = 0; i < max_size; i++)
54 delay_ = delay < max_size ? delay : max_size - 1;
62 int32_t int_delay =
static_cast<int32_t
>(delay);
63 frac_ = delay -
static_cast<float>(int_delay);
64 delay_ =
static_cast<size_t>(int_delay) < max_size ? int_delay
70 inline void Write(
const T sample)
72 line_[write_ptr_] = sample;
73 write_ptr_ = (write_ptr_ - 1 + max_size) % max_size;
78 inline const T
Read()
const
80 T a = line_[(write_ptr_ + delay_) % max_size];
81 T b = line_[(write_ptr_ + delay_ + 1) % max_size];
82 return a + (b - a) * frac_;
86 inline const T
Read(
float delay)
const
88 int32_t delay_integral =
static_cast<int32_t
>(delay);
89 float delay_fractional = delay -
static_cast<float>(delay_integral);
90 const T a = line_[(write_ptr_ + delay_integral) % max_size];
91 const T b = line_[(write_ptr_ + delay_integral + 1) % max_size];
92 return a + (b - a) * delay_fractional;
95 inline const T ReadHermite(
float delay)
const
97 int32_t delay_integral =
static_cast<int32_t
>(delay);
98 float delay_fractional = delay -
static_cast<float>(delay_integral);
100 int32_t t = (write_ptr_ + delay_integral + max_size);
101 const T xm1 = line_[(t - 1) % max_size];
102 const T x0 = line_[(t) % max_size];
103 const T x1 = line_[(t + 1) % max_size];
104 const T x2 = line_[(t + 2) % max_size];
105 const float c = (x1 - xm1) * 0.5f;
106 const float v = x0 - x1;
107 const float w = c + v;
108 const float a = w + v + (x2 - x0) * 0.5f;
109 const float b_neg = w + a;
110 const float f = delay_fractional;
111 return (((a * f) - b_neg) * f + c) * f + x0;
114 inline const T Allpass(
const T sample,
size_t delay,
const T coefficient)
116 T read = line_[(write_ptr_ + delay) % max_size];
117 T write = sample + coefficient * read;
119 return -write * coefficient + read;
Definition delayline.h:29
void SetDelay(size_t delay)
Definition delayline.h:51
const T Read() const
Definition delayline.h:78
void SetDelay(float delay)
Definition delayline.h:60
const T Read(float delay) const
Definition delayline.h:86
void Write(const T sample)
Definition delayline.h:70
void Reset()
Definition delayline.h:38
void Init()
Definition delayline.h:35
FIR Filter implementation, generic and ARM CMSIS DSP based.
Definition adenv.h:16