aboutsummaryrefslogtreecommitdiff
path: root/guile/starlet/midi-control/faders.scm
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-10-23 11:53:00 +0200
committerThomas White <taw@physics.org>2021-10-23 11:53:00 +0200
commitfead43e69edb5ea62b72a8b97c99efbd10403e68 (patch)
tree2fca7e8fb3ff2f6832b72941282c6ed2ae7989ea /guile/starlet/midi-control/faders.scm
parent1392cdcbdd18f2bc7c137edcccc2c833c86b4e04 (diff)
Handle controller=#f in 'set-midi-control-map!'
Diffstat (limited to 'guile/starlet/midi-control/faders.scm')
-rw-r--r--guile/starlet/midi-control/faders.scm63
1 files changed, 32 insertions, 31 deletions
diff --git a/guile/starlet/midi-control/faders.scm b/guile/starlet/midi-control/faders.scm
index 81764b5..e5f9cd4 100644
--- a/guile/starlet/midi-control/faders.scm
+++ b/guile/starlet/midi-control/faders.scm
@@ -327,34 +327,35 @@
(define (set-midi-control-map! controller new-control-map)
- (let ((old-parameter-controller (get-parameter-controller controller)))
-
- ;; Remove the old parameter controller
- (when old-parameter-controller
- (scrub-parameter-controller! controller old-parameter-controller))
-
- (set-parameter-controller!
- controller
- (make <parameter-controller>
- #:callbacks '()
- #:control-map new-control-map))
-
- ;; If this is the first time, add the callbacks
- (unless old-parameter-controller
-
- ;; Selection changed
- (add-hook!
- selection-hook
- (lambda (fixture-list)
- (update-midi-controls controller fixture-list)))
-
- ;; Value changed
- (add-update-hook! programmer-state
- (lambda (fix attr value source)
- (unless (eq? source controller)
- (update-midi-controls controller (get-selection))))))
-
- ;; If there is a selection, run the callback now
- (let ((current-selection (get-selection)))
- (when current-selection
- (update-midi-controls controller current-selection)))))
+ (when controller
+ (let ((old-parameter-controller (get-parameter-controller controller)))
+
+ ;; Remove the old parameter controller
+ (when old-parameter-controller
+ (scrub-parameter-controller! controller old-parameter-controller))
+
+ (set-parameter-controller!
+ controller
+ (make <parameter-controller>
+ #:callbacks '()
+ #:control-map new-control-map))
+
+ ;; If this is the first time, add the callbacks
+ (unless old-parameter-controller
+
+ ;; Selection changed
+ (add-hook!
+ selection-hook
+ (lambda (fixture-list)
+ (update-midi-controls controller fixture-list)))
+
+ ;; Value changed
+ (add-update-hook! programmer-state
+ (lambda (fix attr value source)
+ (unless (eq? source controller)
+ (update-midi-controls controller (get-selection))))))
+
+ ;; If there is a selection, run the callback now
+ (let ((current-selection (get-selection)))
+ (when current-selection
+ (update-midi-controls controller current-selection))))))