;; amount of curve
;;
;; width is duration of the curve
;;
;; the 'power' value of the curve
;; can be negative!
;;
;; 1.0 or 0.0 = flat (returns 1.0)
;; 1.01 = close to linear
;; 2.0 = normal value
;; 6.0 = steeper curve etc..
;;
;; time 0.0 -> width
(bind-func static gainf:[SAMPLE,i64,i64,SAMPLE]*
(lambda (time width power)
(let ((amp 1.0)
(p:double (convert power))
(t (/ (i64tod time) (i64tod width))))
(if (< p 0.0)
(begin (set! p (fabs p))
(set! t (- 1.0 t))))
(let ((out (* amp (/ (- (pow p t) 1.0) (- p 1.0)))))
(convert
(if (> out amp) amp
(if (< out 0.0) 0.0
out)))))))