[CM] Receiving OSC

Kjetil S. Matheussen k.s.matheussen at notam02.no
Tue Oct 28 11:55:20 PDT 2008

On Thu, 23 Oct 2008, Kjetil S. Matheussen wrote:

> I'm no expert in OSC, but I think using a C library, such as
> liblo would be easier to use in Snd than OscPack,
> which is a C++ library.
> Here's an example client: 
> http://liblo.svn.sourceforge.net/viewvc/liblo/trunk/examples/example_client.c?revision=121&view=markup
> Using eval-c, the example (up to the first "send" command only
> and without the "blob"), can be written like this:
> (eval-c-add-int-type "int32_t")
> (eval-c "-llo"
>        "#include <lo/lo.h>"
>        (proto->public
>         "lo_address lo_address_new(const char *host, const char *port);
>          int lo_send_message (lo_address targ, const char *path, lo_message 
> msg);
>          lo_message lo_message_new (void);
>          void lo_message_free (lo_message m);
>          void lo_message_add_int32 (lo_message m, int32_t a);
>          void lo_message_add_float (lo_message m, float a);
>          void lo_message_add_string (lo_message m, const char *a);"))
> (define t (lo_address_new #f "7770"))
> (define message (lo_message_new))
> (lo_message_add_float message 0.12345678)
> (lo_message_add_float message 23.0)
> (define result (lo_send_message t "/foo/bar" message))
> I don't know how easy it is to receive OSC though. That's probably
> a lot harder, but by using "in" to poll a ringbuffer, it isn't
> impossible to do without having to modify snd itself.

I had a strong urge to procrastrinate a little bit from
my normal work, so I wrote an osc receiver as well:

(load-from-path "osc.scm")

(define port 6012)
(osc_start_server port)

(osc_add_callback (lambda (path . args)
                     (c-display "path: " path ", args:" args)))

(osc_send #f port "/foo/bar" 5.2 9.4 "hello" 5)

will print:

path:  /foo/bar , args: (5.19999980926514 9.39999961853027 "hello" 5)

Bill, please include osc.scm in Snd if you want to.

More information about the Cmdist mailing list