aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-04-18 12:19:19 +0200
committerThomas White <taw@physics.org>2021-04-18 12:58:53 +0200
commit3860d3872e69c7fa89015d74ea552cc25fe6e8d7 (patch)
treecaa24b7039b3f744153cc085d3f1b47bd8ed9895
parentf02b353e84d4fea27630216dca8a8c7aa144b77d (diff)
Special case colour components for MIDI faders
-rw-r--r--guile/starlet/midi-control/faders.scm13
1 files changed, 9 insertions, 4 deletions
diff --git a/guile/starlet/midi-control/faders.scm b/guile/starlet/midi-control/faders.scm
index 0b8f3d7..d0f9ab2 100644
--- a/guile/starlet/midi-control/faders.scm
+++ b/guile/starlet/midi-control/faders.scm
@@ -73,7 +73,7 @@
fixture-list attrs)))
(define (clamp-to-attr-range attr-obj val)
- (let ((r (get-attr-range attr-obj)))
+ (let ((r (get-attr-range-maybe-colour attr-obj)))
(max (car r)
(min (cadr r)
val))))
@@ -111,11 +111,16 @@
fixtures old-vals)))))))
+(define (get-attr-range-maybe-colour attr-obj)
+ (if (colour-attribute? attr-obj)
+ '(0 100)
+ (get-attr-range attr-obj)))
+
(define (fader-congruent vals attrs)
(mean (map (lambda (val attr)
(scale-to-range val
- (get-attr-range attr)
+ (get-attr-range-maybe-colour attr)
'(0 127)))
vals attrs)))
@@ -124,7 +129,7 @@
attrs
congruent-val)
(map (lambda (initial-val attr)
- (let ((attr-max (cadr (get-attr-range attr))))
+ (let ((attr-max (cadr (get-attr-range-maybe-colour attr))))
(if (< congruent-val 127)
(/ (- attr-max initial-val)
(- 127 congruent-val))
@@ -137,7 +142,7 @@
attrs
congruent-val)
(map (lambda (initial-val attr)
- (let ((attr-min (car (get-attr-range attr))))
+ (let ((attr-min (car (get-attr-range-maybe-colour attr))))
(if (> congruent-val 0)
(/ (- initial-val attr-min)
congruent-val)