File: utils.expr

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (14 lines) | stat: -rw-r--r-- 405 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 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)
    )
)