make-envelope

(make-envelope points [whole-num?])

Description:

Creates an evelope using points which can be either a list of pairs ((x . y) (x . y)) or a flat vector #(x y x y)

Arguments:

whole-num? -- should we round all results to whole integer value?. this is an optional argument and defaults to #f.

points -- either a list of pairs ((x . y) (x . y)) or a flat vector #(x y x y)

Returns: closure

Examples:

(define inst (au:make-node "aumu" "dls " "appl"))

(au:connect-node inst 0 *au:output-node* 0)

(au:update-graph)

; program change

(au:midi-out (now) inst *io:midi-pc* 0 8 0)

;; x is time and is spread at one beat intervals (i.e. 1.0 2.0 3.0 4.0 etc.)

;; y is random between 0 - 127

(define x (make-vector-with-proc 60 (lambda (i) i)))

(define y (make-vector-with-proc 60 (lambda (i) (random 40 100))))

;; create a combined vector of 60 points

(define points (make-vector 120))

(vector= points x '(0 60 2))

(vector= points y '(1 60 2))

(print points)

;; createv envelope from points

(define env (make-envelope points #t))

;; play for length of envelope (60.0 beats) choosing pitches and volumes from env

;; note: values retured from envelope may not be whole numbers and may need rounding

(define loop

(lambda (time beats)

(play-note time inst

(quantize-pc (env beats) '(0 2 4 7 9))

(- 127 (round (env beats)))

22050)

(if (< beats 60)

(callback (+ time 2000) loop

(+ time 2756)

(+ 0.125 beats))

(print "DONE"))))

;; start

(loop (now) 0.0)

Back to index