I want to use classes for my game logic. But when creating the first one I got an error. I think I do everything according the standard.
This is the code:
class Biquad
{
mA1=0;
mA2=0;
mB0=1.0;
mB1=0;
mB2=0;
mX1=0;
mX2=0;
mY1=0;
mY2=0;
constructor() {
}
init(a1, a2, b0, b1, b2) {
// see https://arachnoid.com/BiQuadDesigner/index.html for calculator
this.mA1 = a1;
this.mA2 = a2;
this.mB0 = b0;
this.mB1 = b1;
this.mB2 = b2;
this.mX1 = 0;
this.mX2 = 0;
this.mY1 = 0;
this.mY2 = 0;
}
initVal(val) {
this.mX1 = val;
this.mX2 = val;
this.mY1 = val;
this.mY2 = val;
}
initAllPass() {
this.mA1 = 0;
this.mA2 = 0;
this.mB0 = 1.0;
this.mB1 = 0;
this.mB2 = 0;
this.mX1 = 0;
this.mX2 = 0;
this.mY1 = 0;
this.mY2 = 0;
}
initLowPass(fs, fc, Q) {
this.updateLowPass(fs, fc, Q);
this.mX1 = 0;
this.mX2 = 0;
this.mY1 = 0;
this.mY2 = 0;
}
updateLowPass(fs, fc, Q) {
const w0 = 2.0 * Math.PI * fc / fs;
const a = sin(w0) / (2.0 * Q);
const a0 = 1.0 + a;
this.mA1 = (-2.0 * cos(w0)) / a0;
this.mA2 = (1.0 - a) / a0;
this.mB1 = (1.0 - cos(w0)) / a0;
this.mB0 = this.mB1 / 2.0;
this.mB2 = this.mB0;
}
initHighPass(fs, fc, Q) {
this.updateHighPass(fs, fc, Q);
this.mX1 = 0;
this.mX2 = 0;
this.mY1 = 0;
this.mY2 = 0;
}
updateHighPass(fs, fc, Q) {
const w0 = 2.0 * Math.PI * fc / fs;
const a = sin(w0) / (2.0 * Q);
const a0 = 1.0 + a;
this.mA1 = (-2.0 * cos(w0)) / a0;
this.mA2 = (1.0 - a) / a0;
this.mB1 = -(1.0 + cos(w0)) / a0;
this.mB0 = -this.mB1 / 2.0;
this.mB2 = this.mB0;
}
filter(x) {
const y = this.mB0 * x + this.mB1 * this.mX1 + this.mB2 * this.mX2 - this.mA1 * this.mY1 - this.mA2 * this.mY2;
this.mX2 = this.mX1;
this.mX1 = x;
this.mY2 = this.mY1;
this.mY1 = y;
return y;
}
}
This is the error: