;;
;; moog VCF variation 2
;;
;; from Stilson/Smith CCRMA
;;
;; type is:
;; lp 1 (or anything)
;; hp 2
;; bp 3
(bind-func static vcf_c
(lambda (type)
(let ((x 0.0) (y1 0.0) (y2 0.0) (y3 0.0) (y4 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 (- (* 2.0 (sin (* f (/ SPI 2.0)))) 1.0))
(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)))