Skip to content

Commit

Permalink
Fix biquad beta calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
beserge committed Dec 20, 2023
1 parent 9a84483 commit 399bf7b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/Filters/biquad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ void Biquad::Reset()
{
float con = cutoff_ * two_pi_d_sr_;
float alpha = 1.0f - 2.0f * res_ * cosf(con) * cosf(con)
+ res_ * res_ * cosf(2 * con);
float beta = 1.0f + cosf(con);
float gamma = 1 + cosf(con);
+ res_ * res_ * cosf(2.f * con);
float beta = res_ * res_ * sinf(2.f * con) - 2.f * res_ * cosf(con) * sinf(con);
float gamma = 1.f + cosf(con);
float m1 = alpha * gamma + beta * sinf(con);
float m2 = alpha * gamma - beta * sinf(con);
float den = sqrtf(m1 * m1 + m2 * m2);
Expand All @@ -19,7 +19,7 @@ void Biquad::Reset()
b1_ = b0_;
b2_ = 0.0f;
a0_ = 1.0f;
a1_ = -2.0 * res_ * cosf(con);
a1_ = -2.0f * res_ * cosf(con);
a2_ = res_ * res_;
}

Expand All @@ -28,8 +28,8 @@ void Biquad::Init(float sample_rate)
sample_rate_ = sample_rate;
two_pi_d_sr_ = TWOPI_F / sample_rate_;

cutoff_ = 500;
res_ = 0.7;
cutoff_ = 500.f;
res_ = 0.7f;

Reset();

Expand Down

0 comments on commit 399bf7b

Please sign in to comment.