(bind-func static lpf2_c
"a state variable lowpass filter. slightly more flops than lpf_c,
but v1 and v2 can be computed in parallel"
(lambda ()
(let ((ic1eq 0.0) (ic2eq 0.0)
(g 0.0)
(k 0.0)
(a1 0.0) (a2 0.0) (a3 0.0)
(v1 0.0) (v2 0.0) (v3:SAMPLE 0.0))
(lambda (in cutoff res)
(set! g (tan (* SPI (/ cutoff SRs))))
(set! k (- 2.0 (* 2.0 res)))
(set! a1 (/ 1.0 (+ 1.0 (* g (+ g k )))))
(set! a2 (* g a1))
(set! a3 (* g a2))
(set! v3 (- in ic2eq))
(set! v1 (+ (* a1 ic1eq) (* a2 v3)))
(set! v2 (+ ic2eq (* a2 ic1eq) (* a3 v3)))
(set! ic1eq (- (* 2.0:f v1) ic1eq))
(set! ic2eq (- (* 2.0 v2) ic2eq))
v2))))