shorepine / amy

AMY - the Additive Music synthesizer librarY

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VCF explosion

dpwe opened this issue · comments

As revealed by the TestFilter sweep, the variable LPF with resonance 8.0 starts generating noise as the break frequency falls below around 700 Hz:
Screenshot 2023-12-18 at 08 27 18
This is presumably overflow in the intermediate accumulator; using a velocity of 0.1 in the test (instead of 1.0) allows the filter to get to around 400 Hz before distortion.

It might be mitigated by reversing the application of poles and zeros in the filter, or we might need to implement higher-headroom arithmetic in the filter. The coefficients seem to be still well-represented: This debug output shows the actual coefficients, first calculated in float, then in their SAMPLE representation, around the point where the distortion begins:

Flpf f=781.438049 q=8.000000 b0 0.003074 b1 0.006149 b2 0.003074 a1 -1.973910 a2 0.986207
Slpf f=781.438049 q=8.000000 b0 0.003074 b1 0.006149 b2 0.003074 a1 -1.973910 a2 0.986207
Flpf f=750.013062 q=8.000000 b0 0.002833 b1 0.005666 b2 0.002833 a1 -1.975424 a2 0.986756
Slpf f=750.013062 q=8.000000 b0 0.002833 b1 0.005666 b2 0.002833 a1 -1.975424 a2 0.986756
Flpf f=719.796265 q=8.000000 b0 0.002610 b1 0.005221 b2 0.002610 a1 -1.976843 a2 0.987285
Slpf f=719.796265 q=8.000000 b0 0.002610 b1 0.005221 b2 0.002610 a1 -1.976843 a2 0.987285
Flpf f=690.788452 q=8.000000 b0 0.002405 b1 0.004810 b2 0.002405 a1 -1.978172 a2 0.987792
Slpf f=690.788452 q=8.000000 b0 0.002405 b1 0.004810 b2 0.002405 a1 -1.978172 a2 0.987792
Flpf f=662.686951 q=8.000000 b0 0.002214 b1 0.004428 b2 0.002214 a1 -1.979429 a2 0.988284
Slpf f=662.686951 q=8.000000 b0 0.002214 b1 0.004428 b2 0.002214 a1 -1.979429 a2 0.988284

I implemented a direct form I biquad (in c9a4bbe) which improved the stability somewhat (because the zeros are applied before the poles, so the intermediate values are small not large). Scaling down the input before filtering doesn't help in that case.

After more consideration (see doc), I added some scale-up around the Direct Form I filter (to avoid underflow) which made the filter behave tolerably for the TestFilter case. See 7d6df2d.
Screenshot 2023-12-19 at 17 40 37