cookdsp icon indicating copy to clipboard operation
cookdsp copied to clipboard

Broken Filters:

Open micsthepick opened this issue 1 year ago • 0 comments

butbp and butbr, and possibly others, are broken due to a read to this.ny before assigning this.ny.

function butbp(freq q)
(
    freq < 1.0 ? freq = 1.0 : freq > this.ny ? freq = this.ny;
    this.freq = freq; 
    q < 0.5 ? q = 0.5 : q > 1000 ? q = 1000;
    this.q = q; 
    this.x1 = this.x2 = this.y1 = this.y2 = 0.0;
    this.pioversr = $pi / srate;
    this.ny = srate * 0.49;
    this._butbp_compute_coeffs();
);

function butbp_set_freq(freq)
(
    freq < 1.0 ? freq = 1.0 : freq > this.ny ? freq = this.ny;
    this.freq = freq; 
    this._butbp_compute_coeffs();
);

This may go unnoticed due to set_freq getting called during slider code after init code, but if your code doesn't ever change the center freq with that method (..._set_freq), then it breaks.

micsthepick avatar Mar 09 '25 23:03 micsthepick