;; mono in (ignores all other channels)
;; pan value [0.0-1.0]
(bind-func static panner_c
(lambda (channels)
(let ((v:SAMPLE 0.0)
(out:SAMPLE 0.0))
(lambda (chan x:SAMPLE pan)
(if (= chan 0) (set! out x))
(set! v (fabs (- (* (- channels 1.0) pan) (convert chan))))
(if (> v 1.0) 0.0
(* (- 1.0 v) out))))))