65 float f = freq_hz /
static_cast<float>(sample_rate_);
66 if (f > 0.497f) f = 0.497f;
68 h_ = 1.0f / (1.0f + r_ * g_ + g_ * g_);
78 r_ = (1.0f - q) * 2.0f;
79 h_ = 1.0f / (1.0f + r_ * g_ + g_ * g_);
113 float g = g_, r = r_, h = h_;
114 float comp = comp_gain_;
115 float s1 = state_1_, s2 = state_2_;
117 for (uint16_t i = 0; i < frames; ++i) {
118 float x = buf[i] * comp;
119 float hp = (x - r * s1 - g * s1 - s2) * h;
120 float bp = g * hp + s1;
122 float lp = g * bp + s2;
130 default: buf[i] = lp;
break;
163 const float* mod,
float center,
float depth,
164 float lo = 20.0f,
float hi = 20000.0f) {
166 float comp = comp_gain_;
167 float s1 = state_1_, s2 = state_2_;
168 float sr =
static_cast<float>(sample_rate_);
170 for (uint16_t i = 0; i < frames; ++i) {
176 if (f > 0.497f) f = 0.497f;
178 float h = 1.0f / (1.0f + r * g + g * g);
181 float x = buf[i] * comp;
182 float hp = (x - r * s1 - g * s1 - s2) * h;
183 float bp = g * hp + s1;
185 float lp = g * bp + s2;
193 default: buf[i] = lp;
break;
201 float f_last =
signal::exp_mod(center, mod[frames - 1], depth, lo, hi) / sr;
202 if (f_last > 0.497f) f_last = 0.497f;
204 h_ = 1.0f / (1.0f + r_ * g_ + g_ * g_);
214 void update_comp_gain() {
215 comp_gain_ = (comp_k_ > 0.0f)
216 ? 1.0f / (1.0f + q_ * comp_k_)
224 float comp_k_ = 0.0f;
225 float comp_gain_ = 1.0f;
226 float state_1_ = 0.0f;
227 float state_2_ = 0.0f;
229 uint32_t sample_rate_ = 48000;
float fast_tan_pif(float f)
float exp_mod(float base, float mod, float depth, float lo=20.0f, float hi=20000.0f)