diff options
author | Thomas White <taw@physics.org> | 2020-08-22 10:02:41 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-08-22 10:02:41 +0200 |
commit | e5c10f8ad742ca8bb157e96e477931758a4866f1 (patch) | |
tree | eaf955187f2acbfd413ceae5237c47b09d15ae50 /examples | |
parent | c3f01023c325a3a378b2c25fd054456058b199f8 (diff) |
Factor out common code in demo
Diffstat (limited to 'examples')
-rw-r--r-- | examples/demo.scm | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/examples/demo.scm b/examples/demo.scm index 007e651..06ebcd0 100644 --- a/examples/demo.scm +++ b/examples/demo.scm @@ -101,30 +101,25 @@ ;; Jump to zero (blackout) cue (cut-to-cue-number! pb 0) -;; Left-hand playback buttons -(define go1 (make-midi-led #:channel 14 #:note-number 20)) -(set-midi-led! go1 #t) -(define stop1 (make-midi-led #:channel 14 #:note-number 24)) -(set-midi-led! stop1 #t) -(register-midi-note-callback! - #:channel 14 - #:note-number 12 - #:func (lambda () (go! pb))) -(register-midi-note-callback! - #:channel 14 - #:note-number 24 - #:func (lambda () (display "Stop/back!\n"))) - -;; Right-hand playback buttons -(define go2 (make-midi-led #:channel 14 #:note-number 23)) -(set-midi-led! go2 #t) -(define stop2 (make-midi-led #:channel 14 #:note-number 27)) -(set-midi-led! stop2 #t) -(register-midi-note-callback! - #:channel 14 - #:note-number 15 - #:func (lambda () (go! pb))) -(register-midi-note-callback! - #:channel 14 - #:note-number 27 - #:func (lambda () (display "Stop/back!\n"))) +(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) |