aboutsummaryrefslogtreecommitdiff
path: root/examples/demo.scm
blob: 359b99b24de24a1a42743c99a81a2d77aab38b9b (plain)
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
;; Example invokation, from top level project folder:
;; $ guile -L guile -l examples/demo.scm

(use-modules
  (starlet base)
  (starlet playback)
  (starlet effects)
  (venues demo-venue)
  (guile-midi control))

(start-ola-output)
(start-midi-control "/dev/snd/midiC1D0")
(all-notes-off! 14)


;; Set up working lights on a MIDI fader
(define working-light-fader
  (make-midi-controller! #:channel 14
                         #:cc-number 19))

(register-state!
 (lighting-state
  (let ((fader-pos (lambda (time)
                     (get-controller-value working-light-fader))))
    (at dim11 'intensity fader-pos)
    (at dim12 'intensity fader-pos)
    (at dim13 'intensity fader-pos))))



;; Same, for some different fixtures

(define movers-fader
  (make-midi-controller! #:channel 14
                         #:cc-number 18))

(register-state!
 (lighting-state
  (let ((fader-pos (lambda (time)
                     (get-controller-value movers-fader))))
    (at mh1 'intensity fader-pos)
    (at mh2 'intensity fader-pos))))


(define pot1
  (make-midi-controller! #:channel 14
                         #:cc-number 7))


(define example-state-1
  (lighting-state

   ;; Front wash
   (at dim11 'intensity 50)
   (at dim12 'intensity 50)
   (at dim13 'intensity 50)

   ;; Sidelight
   (at dim7 'intensity (flash 2))
   (at dim8 'intensity 50)

   (at dim48 'intensity
       (lambda (a)
         (get-controller-value pot1)))))


(define example-state-2
  (lighting-state

   ;; Front wash
   (at dim1 'intensity 10)
   (at dim2 'intensity 10)
   (at dim3 'intensity 10)

   ;; Sidelight
   (at dim7 'intensity (flash 5))))


(define cue-list
  (list (cue 0 make-empty-state
             #:fade-up 1
             #:fade-down 1)

        (cue 1 (lambda () example-state-1)
             #:fade-up 3
             #:fade-down 5)

        (cue 2 (lambda () example-state-2)
             #:fade-up 3
             #:fade-down 1
             #:down-delay 3)

        (cue 3 make-empty-state
             #:fade-up 0
             #:fade-down 2)))


;; Create a playback for the cue list, and register it for output
(define pb
  (make-playback cue-list))
(register-state! pb)

;; Jump to zero (blackout) cue
(cut-to-cue-number! pb 0)

(define (make-playback-buttons chan
                               go-led-note
                               go-button-note
                               stop-led-note
                               stop-button-note)
  (let ((go-led (make-midi-led #:channel chan
                               #:note-number go-led-note))
        (stop-led (make-midi-led #:channel chan
                                 #:note-number stop-led-note)))
    (set-midi-led! go-led #t)
    (set-midi-led! stop-led #t)
    (register-midi-note-callback!
     #:channel chan
     #:note-number go-button-note
     #:func (lambda () (go! pb)))
    (register-midi-note-callback!
     #:channel chan
     #:note-number stop-button-note
     #:func (lambda () (display "Stop/back!\n")))))

(make-playback-buttons 14 20 12 24 24)
(make-playback-buttons 14 23 15 27 27)