gilTclOSC is a lightweight extension of Tcl to format and parse Open Sound Control messages. gilTclOSC does not provide any transport services for the OSC packets: transport is done with Tcl TCP services (the socket command) or the tcl-udp Tcl extension (tcl udp is included in the GIL distribution).


gilTclOSC is part of the GIL distribution.


Easiest way

The easiest way is to execute the following line in your Tcl interpreter:

 source ${where_gil_is_installed}/src/srcipt/gil_Init.tcl

this loads all GIL extensions in your interpreter (including giltclosc), plus the tcludp extension that comes with the GIL distribution.

Selective way

If you prefer to only load the giltclosc extension, do one of:

 load ${where_gil_is_installed}/bin/osx/libgiltclosc.dylib    |
 load ${where_gil_is_installed}/bin/x11/       |
 load ${where_gil_is_installed}/bin/win/giltclosc.dll

depending on your platform.

For udp transport services, load the tcl udp extension in your interpreter. This can be done either with:

 package require udp

if the extension is installed on your system, or with:

 load ${where_gil_is_installed}/bin/osx/libudp*.dylib    |
 load ${where_gil_is_installed}/bin/x11/libudp*.so       |
 load ${where_gil_is_installed}/bin/win/udp*.dll

(replace * by the version number of the extension provided with the distribution).

Tcl commands

gilTclOSC adds the osc_write and osc_read Tcl commands for formatting and parsing OSC packets.

OSC packet formatted as a list

The osc_read command returns an OSC packets formatted as a Tcl list either in the compact form or the detailed form. The osc_write command takes as an argument a list formatted in the detailed form.

Detailed form

The list can either represent an OSC bundle or an OSC message. List representing bundles have the string #bundle as their first element, and other elements must be properly formatted OSC message lists.

 { #bundle <message> <message> ... }

An OSC message list starts with an address pattern (such as: /some/address), followed by an even number of type specifiers and values.

 { <address_pattern> <type_specifier1> <value1> <type_specifier2> <value2> ... }

where the type specifier is one of:

type specifiertype of value
ffloating point number
bany kind of data

Compact form

When returning an OSC packet list in the compact form, osc_read omits the type specifier in the messages:

 { <address_pattern> <value1> <value2> ... }


 osc_write $channel   { /test i 12 i -1 }

 osc_write $channel   [list #bundle [list /test i 13] \
[list /another/test i 1 f 3.4 s "toto" \
b [binary format H* 56e4a0ff] ] ] puts [osc_read -compact $channel] -> { /yet/another/test 23 hello 3.4 }


The GIL distribution includes the Tcl scripts of an OSC demo application.

Page last modified on October 21, 2008, at 10:28 PM
Contacts: the GIL mailing list.