diff options
author | Thomas White <taw@physics.org> | 2023-04-16 17:22:09 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-04-16 17:22:09 +0200 |
commit | 63ea7c9d6f43ff80695507afe8c2db2e3be2b247 (patch) | |
tree | db5ade552925667a7a192cb7abd85f6dabbea02e /guile-osc.c | |
parent | 6ad376342fd56fcac702956e7046e6dc5adbd5ad (diff) |
osc-send: Send arguments
Only int and float implemented so far.
Diffstat (limited to 'guile-osc.c')
-rw-r--r-- | guile-osc.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/guile-osc.c b/guile-osc.c index 7c09637..50ce99e 100644 --- a/guile-osc.c +++ b/guile-osc.c @@ -146,11 +146,31 @@ static SCM osc_send(SCM addr_obj, SCM path_obj, 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); - lo_send(addr, path, ""); + + n_args = scm_to_int(scm_length(rest)); + + message = lo_message_new(); + for ( i=0; i<n_args; i++ ) { + SCM item = scm_list_ref(rest, scm_from_int(i)); + + if ( scm_is_true(scm_real_p(item)) ) { + lo_message_add_double(message, scm_to_double(item)); + } else if ( scm_is_true(scm_integer_p(item)) ) { + lo_message_add_int32(message, scm_to_int(item)); + } else { + fprintf(stderr, "Unrecognised type\n"); + } + } + + lo_send_message(addr, path, message); + lo_message_free(message); return SCM_UNSPECIFIED; } |