diff options
author | Thomas White <taw@bitwiz.me.uk> | 2020-12-27 11:06:35 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2020-12-27 11:06:35 +0100 |
commit | a5b9740fdbde423d4830c8eb8cafa70011cfe948 (patch) | |
tree | 199887dc651aa8fff3770f3e7667ceb51772f3ba | |
parent | d1d8f243d7fe8144b7d30a80e7db3fe4d9f06d3d (diff) |
Add fader control
-rw-r--r-- | guile/starlet/base.scm | 8 | ||||
-rw-r--r-- | guile/starlet/midi-control/faders.scm | 25 |
2 files changed, 31 insertions, 2 deletions
diff --git a/guile/starlet/base.scm b/guile/starlet/base.scm index 4cb9716..ed8472d 100644 --- a/guile/starlet/base.scm +++ b/guile/starlet/base.scm @@ -171,8 +171,12 @@ ;; Set an attribute by name (define (set-attr! state fix attr-name value) - (let ((attr (find-attr fix attr-name))) - (when attr (set-in-state! state fix attr value)))) + (cond + ((symbol? attr-name) + (let ((attr (find-attr fix attr-name))) + (when attr (set-in-state! state fix attr value)))) + ((fixture-attribute? attr-name) + (set-in-state! state fix attr-name value)))) ;; Patch a new fixture diff --git a/guile/starlet/midi-control/faders.scm b/guile/starlet/midi-control/faders.scm new file mode 100644 index 0000000..db1e986 --- /dev/null +++ b/guile/starlet/midi-control/faders.scm @@ -0,0 +1,25 @@ +(define-module (starlet midi-control faders) + #:use-module (starlet midi-control base) + #:use-module (starlet base) + #:export (on-fader)) + + +(define (on-fader channel cc-number state) + (let ((fader (make-midi-controller! #:channel channel + #:cc-number cc-number))) + (register-state! + (lighting-state + (state-for-each + (lambda (fix attr val) + (if (intensity? attr) + + ;; Intensity parameters get scaled according to the fader + (at fix attr (lambda (time) + (* 0.01 + val + (get-controller-value fader)))) + + ;; Non-intensity parameters just get set in our new state + (at fix attr val))) + + state))))) |