aboutsummaryrefslogtreecommitdiff
path: root/guile
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-04-30 17:24:43 +0200
committerThomas White <taw@physics.org>2023-04-30 17:24:43 +0200
commita1084e24db8397097dc7451cc20e6d82732626d5 (patch)
treeeb4502573fdf76b975b3ec1f66fde639b9c45884 /guile
parent0c5f2baf5813d9f492981a8554f5010804c6c708 (diff)
Implement osc-parameter-encoder (basic version)
Diffstat (limited to 'guile')
-rw-r--r--guile/starlet/open-sound-control/utils.scm40
1 files changed, 39 insertions, 1 deletions
diff --git a/guile/starlet/open-sound-control/utils.scm b/guile/starlet/open-sound-control/utils.scm
index 16ccbaf..1d6104e 100644
--- a/guile/starlet/open-sound-control/utils.scm
+++ b/guile/starlet/open-sound-control/utils.scm
@@ -21,12 +21,17 @@
(define-module (starlet open-sound-control utils)
#:use-module (starlet playback)
#:use-module (starlet selection)
+ #:use-module (starlet fixture)
+ #:use-module (starlet engine)
+ #:use-module (starlet state)
#:use-module (starlet utils)
#:use-module (open-sound-control client)
#:use-module (open-sound-control server-thread)
+ #:use-module (srfi srfi-1)
#:export (osc-playback-indicators
osc-playback-controls
- osc-select-button))
+ osc-select-button
+ osc-parameter-encoder))
(define* (osc-playback-controls pb server go-method stop-method back-method
@@ -82,3 +87,36 @@
(osc-send addr led 'orange)
(osc-send addr led 'red)))
(get-selection)))
+
+
+(define (encoder-inc attr n)
+ (for-each
+ (lambda (fix)
+ (at fix attr (+ (current-value fix attr) n)))
+ (get-selection)))
+
+
+(define (osc-parameter-encoder server encoder-method addr led attr)
+
+ (add-osc-method server (string-append encoder-method "/inc") ""
+ (lambda () (encoder-inc attr 3)))
+
+ (add-osc-method server (string-append encoder-method "/dec") ""
+ (lambda () (encoder-inc attr -3)))
+
+ (add-osc-method server (string-append encoder-method "/inc-fine") ""
+ (lambda () (encoder-inc attr 1)))
+
+ (add-osc-method server (string-append encoder-method "/dec-fine") ""
+ (lambda () (encoder-inc attr -1)))
+
+ (add-and-run-hook!
+ selection-hook
+ (lambda (sel)
+ (if (any
+ (lambda (fix)
+ (fixture-has-attr? fix attr))
+ (get-selection))
+ (osc-send addr led 'green)
+ (osc-send addr led 'off)))
+ (get-selection)))