(bind-func static saturation_c
"level:[0.0,1.0] character:[0.0,1.0]"
(lambda ()
(let ((itm1 0.0)
(otm1 0.0))
(lambda (x:SAMPLE level:SAMPLE character:SAMPLE)
(set! level (clamp level .1 0.9))
(let ((q (- level 0.999))
(dist (+ (* character 40.0) 0.1))
(fx (if (= x q)
(/ (/ 1.0 (+ dist q))
(- 1.0 (exp (* dist q))))
(+ (/ (- x q)
(- 1.0 (exp (* -1.0 dist (- x q)))))
(/ q (- 1.0 (exp (* dist q))))))))
(set! otm1 (- (+ (* 0.999 otm1) fx) itm1))
(set! itm1 fx)
otm1)))))