-
Notifications
You must be signed in to change notification settings - Fork 0
/
rs-diag-timing.rkt
82 lines (63 loc) · 2.02 KB
/
rs-diag-timing.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
#lang racket
;; Run multiple sequences to diagnose timing problems.
;; Sequences are:
;; X - - -
;; X - X -
;; - - X -
;;
;; By sending these to your DAW and recording them you can determine
;; by how much the timing of rs is off and / or drifts over time.
;;
;; To prepare, make sure you have at least one MIDI port available and
;; three instruments, one of which listens on channel 1, the other on
;; channel 2 and the third on channel 3
(require rs)
(printf "Available MIDI ports: ~s\n" (rs-m-list-ports))
(when (not (length (rs-m-list-ports)))
(printf "No MIDI ports available. This will not work.\n"))
;; Again, set up a simple 128 BPM loop with 16 sub divisions of 1/4 beats
;; each and start it. Note the ! at the end of these function
;; names. This ! means the function will cause something to happen to
;; the main loop.
(rs-set-global-bpm! 120)
(rs-set-global-div-length! 1/4)
(rs-set-global-steps! 4)
(rs-start-main-loop!)
;; Create instruments.
(define instr1 (rs-m-instr 0 1))
(define instr2 (rs-m-instr 0 2))
(define instr3 (rs-m-instr 0 3))
;; Create events and sequences.
(define i1note (rs-m-event-play instr1 48 100 90))
(define i2note (rs-m-event-play instr2 55 100 90))
(define i3note (rs-m-event-play instr3 60 100 90))
(define i1seq (list i1note
null
null
null))
(define i2seq (list i2note
null
i2note
null))
(define i3seq (list null
null
i3note
null))
;; Create tracks for each instrument. They can use the main loop settings for now.
(define track1 (rs-track i1seq))
(define track2 (rs-track i2seq))
(define track3 (rs-track i3seq))
;; Cue and stop the tracks.
(rs-queue-track! track1)
(sleep 4.0)
(rs-queue-track! track2)
(sleep 4.0)
(rs-queue-track! track3)
(sleep 16.0)
(rs-stop-track! 0)
(sleep 4.0)
(rs-stop-track! 0)
(sleep 4.0)
(rs-stop-track! 0)
;; We're done. Stop the main loop. The performance is over.
(rs-stop-main-loop!)