| 1 |
//---------------------------------------------------------------------------- |
| 2 |
// name: osc-dump.ck |
| 3 |
// desc: listen to and print all OSC messages on specified port |
| 4 |
// for example, launch this with s.ck |
| 5 |
// (make sure port is the same in both sender and receiver) |
| 6 |
//---------------------------------------------------------------------------- |
| 7 |
|
| 8 |
// OSC in |
| 9 |
OscIn oin; |
| 10 |
|
| 11 |
// see if port is supplied on command line |
| 12 |
if( me.args() ) me.arg(0) => Std.atoi => oin.port; |
| 13 |
// default port |
| 14 |
else 6449 => oin.port; |
| 15 |
|
| 16 |
// print |
| 17 |
cherr <= "listening for OSC messages over port: " <= oin.port() |
| 18 |
<= "..." <= IO.newline(); |
| 19 |
// listen to everything coming |
| 20 |
oin.listenAll(); |
| 21 |
|
| 22 |
// something to shuttle data |
| 23 |
OscMsg msg; |
| 24 |
|
| 25 |
// infinite time loop |
| 26 |
while( true ) |
| 27 |
{ |
| 28 |
// wait for OSC input |
| 29 |
oin => now; |
| 30 |
|
| 31 |
// drain the message queue |
| 32 |
while( oin.recv(msg) ) |
| 33 |
{ |
| 34 |
// print address and typetag |
| 35 |
cherr <= msg.address <= " " <= msg.typetag <= " "; |
| 36 |
// loop over number of arguments by type |
| 37 |
for(int n; n < msg.numArgs(); n++) |
| 38 |
{ |
| 39 |
// print by type |
| 40 |
if(msg.typetag.charAt(n) == 'i') |
| 41 |
cherr <= msg.getInt(n) <= " "; |
| 42 |
else if(msg.typetag.charAt(n) == 'f') |
| 43 |
cherr <= msg.getFloat(n) <= " "; |
| 44 |
else if(msg.typetag.charAt(n) == 's') |
| 45 |
cherr <= msg.getString(n) <= " "; |
| 46 |
} |
| 47 |
// print newline |
| 48 |
cherr <= IO.nl(); |
| 49 |
} |
| 50 |
} |