PageRenderTime 13ms CodeModel.GetById 7ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/temporal_recursion_101.scm

http://github.com/digego/extempore
Lisp | 30 lines | 15 code | 5 blank | 10 comment | 0 complexity | 682ed1dd6ed0564cff2cc5a8de81e620 MD5 | raw file
 1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 2;
 3; Good old temporal recursion at it's simplest
 4;
 5
 6
 7;
 8; temporal recursion
 9;
10(define	tr
11  (lambda (t x rate)
12    (println t x)
13    (callback (+ t rate) 'tr (+ t rate) x rate)))
14
15(let ((t (now)))
16  tr t "a" (* 4 44100))
17  (tr t " b" (* 2 44100))
18  (tr t "  c" 44100))
19
20;
21; metro also works
22;
23(define metro-test
24  (lambda (beat x dur)
25    (println x beat)
26    (callback (*metro* (+ beat dur)) 'metro-test (+ beat dur)
27              x dur)))
28
29(metro-test (*metro* 'get-beat 4.0) "A" 2)
30(metro-test (*metro* 'get-beat 4.0) "--B" 1/2)