aboutsummaryrefslogtreecommitdiff
path: root/extensions/gui/ix
diff options
context:
space:
mode:
authorcarmen rocco <ix9@users.sourceforge.net>2005-11-23 23:19:42 +0000
committercarmen rocco <ix9@users.sourceforge.net>2005-11-23 23:19:42 +0000
commit59bc5841c63961260c70979877df3fc781f8cf30 (patch)
treebbd87ab247d37dbefc9d1b1685faa6d44e371901 /extensions/gui/ix
parentc5046871ef4fe695aed8c971664fdc6d408209b8 (diff)
tcl's first OSC implementation? pathetic!
svn path=/trunk/; revision=4027
Diffstat (limited to 'extensions/gui/ix')
-rw-r--r--extensions/gui/ix/osc.tcl43
1 files changed, 43 insertions, 0 deletions
diff --git a/extensions/gui/ix/osc.tcl b/extensions/gui/ix/osc.tcl
new file mode 100644
index 00000000..e5830ec4
--- /dev/null
+++ b/extensions/gui/ix/osc.tcl
@@ -0,0 +1,43 @@
+#OSC tcl 2005 ix
+package require udp
+namespace eval osc {
+ proc encode {type data} {
+ switch $type {
+ i {set format I }
+ f {set format R }
+ s {set len [string length $data]
+ set format a[expr $len + 4 - $len % 4]}
+ }
+ return [binary format $format $data]
+ }
+ proc message {args} {
+ set path [encode s [lindex $args 0]]
+ set typetags ","
+ set body ""
+ foreach arg [lrange $args 1 end] {
+ if [string is integer $arg] {
+ set type i
+ } elseif [string is double $arg] {
+ set type f
+ } else {
+ set type s
+ }
+ append typetags $type
+ append body [encode $type $arg]
+ }
+ set typetags [encode s $typetags]
+ return $path$typetags$body
+ }
+ proc connect {host port} {
+ set s [udp_open]
+ fconfigure $s -remote [list $host $port] -buffering none -translation binary
+ return $s
+ }
+ proc disconnect {socket} {
+ close $socket
+ }
+ proc send {socket msg} {
+ puts -nonewline $socket $msg
+ }
+
+}