summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2024-03-17 10:14:02 +0100
committerThomas White <taw@physics.org>2024-03-17 10:14:02 +0100
commit5dcb31caf88b2ccfd225ff9a4bda546d7d549a2d (patch)
treed29b11f3235c68477ba068f597c4334a28e7c6d8
parent52c58f11955dac3185ea6c6c18776e428cbaf800 (diff)
Add osc-send-from
-rw-r--r--guile-osc.c46
-rw-r--r--open-sound-control/api.scm3
-rw-r--r--open-sound-control/client.scm1
3 files changed, 41 insertions, 9 deletions
diff --git a/guile-osc.c b/guile-osc.c
index 71122e1..237493f 100644
--- a/guile-osc.c
+++ b/guile-osc.c
@@ -295,18 +295,12 @@ static SCM osc_recv(SCM rest)
}
-static SCM osc_send(SCM addr_obj, SCM path_obj, SCM rest)
+static lo_message make_lo_message(SCM rest)
{
- lo_address addr;
- char *path;
int n_args;
lo_message message;
int i;
- scm_assert_foreign_object_type(osc_address_type, addr_obj);
- addr = scm_foreign_object_ref(addr_obj, 0);
- path = scm_to_utf8_stringn(path_obj, NULL);
-
n_args = scm_to_int(scm_length(rest));
message = lo_message_new();
@@ -328,9 +322,44 @@ static SCM osc_send(SCM addr_obj, SCM path_obj, SCM rest)
}
}
- lo_send_message(addr, path, message);
+ return message;
+}
+
+
+static SCM osc_send_from(SCM addr_obj, SCM from_obj, SCM path_obj, SCM rest)
+{
+ lo_address addr;
+ char *path;
+ lo_server server;
+ lo_message message;
+
+ scm_assert_foreign_object_type(osc_address_type, addr_obj);
+ addr = scm_foreign_object_ref(addr_obj, 0);
+ path = scm_to_utf8_stringn(path_obj, NULL);
+
+ scm_assert_foreign_object_type(osc_server_type, from_obj);
+ server = scm_foreign_object_ref(from_obj, 0);
+
+ message = make_lo_message(rest);
+ lo_send_message_from(addr, server, path, message);
lo_message_free(message);
+ return SCM_UNSPECIFIED;
+}
+
+
+static SCM osc_send(SCM addr_obj, SCM path_obj, SCM rest)
+{
+ lo_address addr;
+ char *path;
+ lo_message message;
+ scm_assert_foreign_object_type(osc_address_type, addr_obj);
+ addr = scm_foreign_object_ref(addr_obj, 0);
+ path = scm_to_utf8_stringn(path_obj, NULL);
+
+ message = make_lo_message(rest);
+ lo_send_message(addr, path, message);
+ lo_message_free(message);
return SCM_UNSPECIFIED;
}
@@ -365,6 +394,7 @@ void init_guile_osc()
scm_c_define_gsubr("add-osc-method", 4, 0, 0, add_osc_method);
scm_c_define_gsubr("make-osc-address", 1, 0, 0, make_osc_address);
scm_c_define_gsubr("osc-send", 2, 0, 1, osc_send);
+ scm_c_define_gsubr("osc-send-from", 3, 0, 1, osc_send_from);
scm_add_feature("guile-osc");
}
diff --git a/open-sound-control/api.scm b/open-sound-control/api.scm
index 6ee3c9f..9326654 100644
--- a/open-sound-control/api.scm
+++ b/open-sound-control/api.scm
@@ -26,7 +26,8 @@
osc-recv
make-osc-address
- osc-send))
+ osc-send
+ osc-send-from))
(if (not (provided? 'guile-osc))
diff --git a/open-sound-control/client.scm b/open-sound-control/client.scm
index f50cfec..6e74f47 100644
--- a/open-sound-control/client.scm
+++ b/open-sound-control/client.scm
@@ -21,4 +21,5 @@
(define-module (open-sound-control client)
#:use-module (open-sound-control api)
#:re-export (osc-send
+ osc-send-from
make-osc-address))