-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.rkt
67 lines (56 loc) · 2.56 KB
/
base.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#lang racket
(require arezzo-lite/comp-table-to-alda
arezzo-lite/utils
arezzo-lite/arezzo-tokens)
(provide composition
play!)
(define-syntax-rule
(composition
comp-name
gl-tempo gl-tempo-body
gl-unitr gl-unitr-body
v1-root v1-root-body
v2-root v2-root-body
v3-root v3-root-body
v4-root v4-root-body
v1-oct v1-oct-body
v2-oct v2-oct-body
v3-oct v3-oct-body
v4-oct v4-oct-body
v1-part v1-part-body
v2-part v2-part-body
v3-part v3-part-body
v4-part v4-part-body)
(define comp-name
(comp-table->alda
(hasheqv
gl-tempo (events->tempo-markers (listof-symbol->listof-events gl-tempo-body))
gl-unitr (events->unitr-markers (holds->repeats
(listof-symbol->listof-events gl-unitr-body)))
v1-root (events->root-markers (holds->repeats
(listof-symbol->listof-events v1-root-body)))
v2-root (events->root-markers (holds->repeats
(listof-symbol->listof-events v2-root-body)))
v3-root (events->root-markers (holds->repeats
(listof-symbol->listof-events v3-root-body)))
v4-root (events->root-markers (holds->repeats
(listof-symbol->listof-events v4-root-body)))
v1-oct (events->oct-markers (listof-symbol->listof-events v1-oct-body))
v2-oct (events->oct-markers (listof-symbol->listof-events v2-oct-body))
v3-oct (events->oct-markers (listof-symbol->listof-events v3-oct-body))
v4-oct (events->oct-markers (listof-symbol->listof-events v4-oct-body))
v1-part (events->part-markers (listof-symbol->listof-events v1-part-body))
v2-part (events->part-markers (listof-symbol->listof-events v2-part-body))
v3-part (events->part-markers (listof-symbol->listof-events v3-part-body))
v4-part (events->part-markers (listof-symbol->listof-events v4-part-body))))))
;; Takes the id of a composition and plays it out loud. Requires
;; Alda server to be running. Start the alda server by running `alda up`.
(define (play! comp-id)
(with-handlers
([exn:fail:contract?
(λ (exn) "play! does nothing when run from the racket REPL (or DrRacket). Run `racket this-file.rkt` in a shell while `alda up` is running to hear live playback.")])
(let ([alda-exec-path
(car (string-split (with-output-to-string (λ()
(system "which alda"))) "\n"))])
(system* alda-exec-path "play" "--code" comp-id))
))