Skip to content

Commit

Permalink
Revert AdaptiveNotchCPZ
Browse files Browse the repository at this point in the history
It's not clear, but the modified version seems to adapt faster than the original.
  • Loading branch information
ryukau committed Aug 19, 2024
1 parent f79b458 commit 3409dd9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions common/dsp/adaptivefilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export class AdaptiveFilterLMS {
}
}

// Constrained poles and zeros-based adaptive notch filters (CPZ-ANF) described in section
// II of following paper.
// Adaptive notch filter based on the one described in section II of the paper below.
// Computation of `s0` is modified from the paper.
// - "DSP Implementation of Adaptive Notch Filters With Overflow Avoidance in Fixed-Point
// Arithmetic" by Satoru Ishibashi, Shunsuke Koshita, Masahide Abe and Masayuki
// Kawamata. (http://www.apsipa.org/proceedings/2018/pdfs/0001355.pdf)
Expand Down Expand Up @@ -83,9 +83,8 @@ export class AdaptiveNotchCPZ {
const gain
= this.a >= 0 ? (1 + a1 + a2) / (2 + this.a) : (1 - a1 + a2) / (2 - this.a);

const denom = a1 * this.y1 + a2 * this.y2
const y0 = x0 + this.a * this.x1 + this.x2 - denom;
const s0 = (1 - this.rho) * x0 - this.rho * (1 - this.rho) * this.x2 - denom;
const y0 = x0 + this.a * this.x1 + this.x2 - a1 * this.y1 - a2 * this.y2;
const s0 = this.x1 * (1 - this.rho * y0);
this.a = clamp(this.a - 2 * y0 * s0 * this.mu, -this.aBound, this.aBound);

this.x2 = this.x1;
Expand Down

0 comments on commit 3409dd9

Please sign in to comment.