aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-05-14 21:48:05 +0200
committerThomas White <taw@physics.org>2023-05-14 21:48:05 +0200
commita1feb3a6fe9bdadbc39294ddaf3d07c8655fc9f4 (patch)
tree1d9aecf85f2df712ed7537353b53d7ff54e5a5cc
parentd2138c27ffc90080fe7e0b16a9e7f3109200ee23 (diff)
Send selection via OSC
-rw-r--r--examples/demo-show.scm2
-rw-r--r--guile/starlet/open-sound-control/utils.scm13
-rw-r--r--guile/starlet/selection.scm11
-rw-r--r--guile/starlet/utils.scm10
4 files changed, 34 insertions, 2 deletions
diff --git a/examples/demo-show.scm b/examples/demo-show.scm
index 6d54a01..207e0c7 100644
--- a/examples/demo-show.scm
+++ b/examples/demo-show.scm
@@ -97,6 +97,8 @@
(define osc-server (make-osc-server-thread "osc.udp://:7770"))
(define x1k2 (make-osc-address "osc.udp://localhost:7771"))
+(send-selection-updates-to (make-osc-address "osc.udp://localhost:7772"))
+
(osc-send x1k2 "/x1k2/leds/*" 'off)
(osc-playback-indicators pb x1k2 "/x1k2/leds/101" "/x1k2/leds/29" "/x1k2/leds/25")
diff --git a/guile/starlet/open-sound-control/utils.scm b/guile/starlet/open-sound-control/utils.scm
index 34c4127..4f0a60b 100644
--- a/guile/starlet/open-sound-control/utils.scm
+++ b/guile/starlet/open-sound-control/utils.scm
@@ -33,7 +33,8 @@
osc-playback-controls
osc-select-button
osc-parameter-encoder
- osc-state-fader))
+ osc-state-fader
+ send-selection-updates-to))
(define* (osc-playback-controls pb server go-method stop-method back-method
@@ -151,3 +152,13 @@
(add-osc-method server fader "i"
(lambda (v) (set! fader-val v)))))
+
+
+(define (send-selection-updates-to addr)
+ (add-hook!
+ selection-hook
+ (lambda (sel)
+ (osc-send
+ addr
+ "/starlet/selection/update"
+ (get-selection-as-string)))))
diff --git a/guile/starlet/selection.scm b/guile/starlet/selection.scm
index d0f2c1d..7e5ca1a 100644
--- a/guile/starlet/selection.scm
+++ b/guile/starlet/selection.scm
@@ -20,6 +20,7 @@
;;
(define-module (starlet selection)
#:use-module (starlet utils)
+ #:use-module (starlet fixture)
#:use-module (srfi srfi-1)
#:export (sel
add-sel
@@ -27,6 +28,7 @@
desel
selection-hook
get-selection
+ get-selection-as-string
selected?))
@@ -39,6 +41,15 @@
selection)
+(define (get-selection-as-string)
+ (cat-with-spaces
+ (map
+ (lambda (s)
+ (symbol->string
+ (get-fixture-name s)))
+ selection)))
+
+
(define (sel . fixture-list)
(if (nil? fixture-list)
(set! selection '())
diff --git a/guile/starlet/utils.scm b/guile/starlet/utils.scm
index e1b92a8..e0579ab 100644
--- a/guile/starlet/utils.scm
+++ b/guile/starlet/utils.scm
@@ -41,7 +41,8 @@
comment
hash-table-empty?
lookup
- add-and-run-hook!))
+ add-and-run-hook!
+ cat-with-spaces))
(define (print-hash-table ht)
@@ -179,3 +180,10 @@
(define (add-and-run-hook! hook proc . initial-args)
(add-hook! hook proc)
(apply proc initial-args))
+
+
+(define (cat-with-spaces lst)
+ (reduce
+ (lambda (b a)
+ (string-append a " " b))
+ "" lst))