// Takes a signal in the range [0, 1] and scales it to [min, max] range.
// usage: scale(signal min max)
(define scale (
        (+ (* $1 (- $3 $2)) $2)
    )
)
// Takes a signal in the range [-1, 1] and scales it to [min, max] range.
// usage: scalef(signal min max)
(define scalef (
        (let #middle (* (+ $2 $3) 0.5))
        (let #range (* (- $3 $2) 0.5))
        (+ (* $1 #range) #middle)
    )
)