-
Notifications
You must be signed in to change notification settings - Fork 0
/
rs-demo-drums.rkt
128 lines (105 loc) · 3.04 KB
/
rs-demo-drums.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#lang racket
;; This demo shows how you can sequence drums. It uses the stock
;; Ableton 808 kit on channel 1 of MIDI port 0.
;;
;; An Ableton drum kit has notes assigned to each sample (see
;; below). A useful way to work with these kits is to assign events to
;; each of these notes and give them meaningful names.
;;
;; This demo also makes use of the new nested sequences feature.
(require rs)
(when (not (length (list)))
(printf "No MIDI ports available. This will not work.\n"))
(rs-set-global-bpm! 128)
(rs-set-global-div-length! 1/4)
(rs-set-global-steps! 16)
(rs-start-main-loop!)
;; Uncomment if you want diagnostics. This is awful for performance.
;; (rs-util-set-diag-mode #t)
;; The kit is on channel 1 of MIDI port 0
(define kit (rs-m-instr 0 1))
;; Drum samples map to notes.
(define bd (rs-m-event-play kit 36 25 127))
(define rm (rs-m-event-play kit 37 25 127))
(define sd (rs-m-event-play kit 38 25 127))
(define cp (rs-m-event-play kit 39 25 127))
(define cv (rs-m-event-play kit 40 25 127))
(define tl (rs-m-event-play kit 41 25 127))
(define hc (rs-m-event-play kit 42 25 127))
(define tm (rs-m-event-play kit 43 25 127))
(define mc (rs-m-event-play kit 44 25 127))
(define th (rs-m-event-play kit 45 25 127))
(define ho (rs-m-event-play kit 46 25 127))
(define cl (rs-m-event-play kit 47 25 127))
(define cm (rs-m-event-play kit 48 25 127))
(define cy (rs-m-event-play kit 49 25 127))
(define ch (rs-m-event-play kit 50 25 127))
(define cb (rs-m-event-play kit 51 25 127))
;; To test a sound, uncomment the line below and set the desired sound.
;((rs-e-fn rm) 100)
;; Some sequences to start with.
;; Electro style.
(define seq1 (list
bd
null
null
sd
null
null
))
;; To run a sequence, create a track that uses it and queue it.
(define track1 (rs-track seq1))
(rs-queue-track! track1)
(sleep 4)
;; Add hi hats.
(define hh (list
mc
hc
mc
hc
mc
hc
mc
ho
))
(define track2 (rs-track hh ))
(rs-queue-track! track2)
(sleep 4)
;; Let's change the sequence for track 1
(set-rs-t-seq! track1 (list
bd
bd
null
null
null
null
sd
null
))
(sleep 4)
;; Back to the original sequence for track 1
(set-rs-t-seq! track1 seq1)
(sleep 4)
;; Stop the hihats
(rs-stop-track! 1)
(sleep 4)
;; Bring them back
(rs-queue-track! track2)
(sleep 4)
;; Make them fancier. Lists in lists!
(set-rs-t-seq! track2 (list
mc
hc
mc
(list hc hc)
mc
hc
mc
(list hc hc hc)
))
(sleep 4)
;; Back to regular hi-hats.
(set-rs-t-seq! track2 hh)
(sleep 4)
;; Done
(rs-stop-main-loop!)