;;
;; moog VCF
;;
;; from Stilson/Smith CCRMA
;;
(bind-func static vcf_old_c
(lambda ()
(let ((x 0.0) (y1 0.0) (y2 0.0) (y3 0.0) (y4:SAMPLE 0.0)
(oldx 0.0) (oldy1 0.0) (oldy2 0.0) (oldy3 0.0))
(lambda (in:SAMPLE cutoff res)
(let ((f (* 1.75 (/ cutoff SAMPLERATE)))
(k (- (- (* 3.6 f) (* 1.6 (* f f))) 1.0))
(p (* 0.5 (+ k 1.0)))
(scale (exp (* (- 1.0 p) 1.386249)))
(r (* res scale)))
(set! x (- in (* r y4)))
(set! y1 (+ (* x p) (* oldx p) (* -1.0 k y1)))
(set! y2 (+ (* y1 p) (* oldy1 p) (* -1.0 k y2)))
(set! y3 (+ (* y2 p) (* oldy2 p) (* -1.0 k y3)))
(set! y4 (+ (* y3 p) (* oldy3 p) (* -1.0 k y4)))