| Author |
Message |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Mon Feb 23, 2009 11:16 pm Post subject:
Using ChucK with SwingOSC (for graphical interface) |
 |
|
Okay, so i decided to start this thread for us to share about using ChucK to create GUI with SwingOSC.
And actually now I'm a 99.99% newbie ha ha ha. So here comes the question from a complete beginner like me:
I've been reading the OSC message format in the ChucK manual and SwingOSC Command Reference: http://www.sciss.de/swingOSC/OSC-Command-Reference.html
But still cannot get it to produce anything. I still don't understand how I can format the message correctly. I tried to start from this -
Running SwingOSC on localhost
| Code: | | SwingOSC v0.60. receiving TCP at address 127.0.0.1:57111 |
Then start with this code in ChucK
| Code: | // host name and port
"localhost" => string hostname;
57111 => int port;
// send object
OscSend xmit;
// aim the transmitter
xmit.setHost( hostname, port );
xmit.startMsg("/global, s, f");
xmit.addString("pi");
xmit.addFloat(3.14159);
xmit.startMsg("/print, s");
xmit.addString("pi"); |
But this doens't seem to produce anything at the SwingOSC terminal. (I was intended to have it print out the global variable pi.)
Hmm.. How do I format the strings and the sequence, especially for accessing Java Swing components? |
|
|
Back to top
|
|
 |
Inventor
Stream Operator

Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
|
Posted: Mon Feb 23, 2009 11:46 pm Post subject:
|
 |
|
kijjaz, the only difference i can see between what you show and the example on the ChucK site is that the sendMsg function in the example has two parameters. it appears to have a directory string and a message format string. In your code, however, you have joined these strings together as a single string. Perhaps this is the problem, I don't really know. _________________ "Let's make noise for peace." - Kijjaz |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Tue Feb 24, 2009 12:00 am Post subject:
|
 |
|
Oh it's true Inventor, after checking the examples here http://chuck.cs.princeton.edu/doc/examples/osc/OSC_send.ck , I can see that sending needs the typing to be in a different string.
I might be confused with the receive mechanism that the data types is in the same string, like this: http://chuck.cs.princeton.edu/doc/examples/osc/OSC_recv.ck
after changing the code to this
| Code: | // host name and port
"localhost" => string hostname;
57111 => int port;
// send object
OscSend xmit;
// aim the transmitter
xmit.setHost(hostname, port);
xmit.startMsg("/global", "s f");
xmit.addString("pi");
xmit.addFloat(3.14159);
xmit.startMsg("/print", "s");
xmit.addString("pi"); |
nothing still prints in the SwingOSC terminal. Maybe I'm still missing a lot of basic things. |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Tue Feb 24, 2009 12:35 am Post subject:
|
 |
|
I've switched SwingOSC to using SwingOSC_UDP.sh and finally got something.
| Code: | // host name and port
"localhost" => string hostname;
57111 => int port;
// send object
OscSend xmit;
// aim the transmitter
xmit.setHost(hostname, port);
xmit.startMsg("/print", "s f f");
xmit.addString("love");
xmit.addFloat(-1.5);
xmit.addFloat(10); |
the result int the SwingOSC terminal is:
| Code: | SwingOSC v0.60. receiving UDP at address 127.0.0.1:57111
love : null
getObject : java.lang.ClassNotFoundException : -1.5
-1.5 : null
getObject : java.lang.ClassNotFoundException : 10.0
10.0 : null | Oh! Sorry.. no class or varibles of those names.
and this works now:
| Code: | xmit.startMsg("/global", "s f");
xmit.addString("pi");
xmit.addFloat(3.14159);
xmit.startMsg("/print", "s");
xmit.addString("pi"); |
gives this result:
So I guess at least it can communicate now. Normally I've been using the TCP version all them time with Supercollider and never tried UDP before. I'm gonna spend my free time trying to create and do method with more objects.
edit: By the way, I'm on Ubuntu Intrepid. I'll try on some other platforms as soon as possible. |
|
|
Back to top
|
|
 |
Inventor
Stream Operator

Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 270
|
Posted: Tue Feb 24, 2009 3:05 am Post subject:
|
 |
|
Good, keep us posted kijjaz! _________________ "Let's make noise for peace." - Kijjaz |
|
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
Posted: Tue Feb 24, 2009 8:44 pm Post subject:
|
 |
|
It's probably worth your while to get TCP working. The big problem we had in supercollider with SwingOSC and UDP is that datagrams sent at about the same time might arrive at the GUI server out of order, causing all kinds of havoc. That is, it might receive the message to create a slider before receiving the message to create the containing window.
But, very cool that you've gotten some result out of it!
James _________________ ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net |
|
|
Back to top
|
|
 |
Antimon

Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 373
G2 patch files: 100
|
Posted: Wed Feb 25, 2009 8:45 am Post subject:
|
 |
|
You haven't experienced any latency or buffering issues with TCP? I've used some voluntary hand-shaking stuff on occasion, that problem would be solved by the graphics system saying "Ok, I've created a slider", which the sender could wait for before continuing. During normal operation I think that mostly you don't need that hand-shaking stuff.
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
Posted: Wed Feb 25, 2009 10:22 am Post subject:
|
 |
|
| Antimon wrote: | You haven't experienced any latency or buffering issues with TCP? I've used some voluntary hand-shaking stuff on occasion, that problem would be solved by the graphics system saying "Ok, I've created a slider", which the sender could wait for before continuing. During normal operation I think that mostly you don't need that hand-shaking stuff.
/Stefan |
No, that hasn't been reported at all.
In SC, synchronizing a thread with a server is pretty easy - the problem was backward compatibility. There's TONS of SC code out there that expects GUIs to return synchronously with the completed client-side GUI abstractions, but if you force everyone to make GUIs asynchronously (required for sync) then it just breaks too much stuff. TCP allows the SC code to run synchronously and the SwingOSC server catches up when it can. On localhost this is quite responsive. Maybe it would be a problem running a SwingOSC server on a remote machine.
In ChucK it may be OK to work differently, even something like:
| Code: | // Do something to make a window here
5::ms => now;
// Do something to make a slider here |
Most SC GUIs are fairly low traffic - you wouldn't use SwingOSC for live visuals. Someone else was working on an animation server for that - it's out there on the web somewhere, still early alpha and kind of buggy but promising!
James _________________ ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net |
|
|
Back to top
|
|
 |
Antimon

Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 373
G2 patch files: 100
|
Posted: Wed Feb 25, 2009 10:57 am Post subject:
|
 |
|
| dewdrop_world wrote: | | Antimon wrote: | You haven't experienced any latency or buffering issues with TCP? I've used some voluntary hand-shaking stuff on occasion, that problem would be solved by the graphics system saying "Ok, I've created a slider", which the sender could wait for before continuing. During normal operation I think that mostly you don't need that hand-shaking stuff.
/Stefan |
No, that hasn't been reported at all. |
OK, cool. I've wondered a bit why OSC is often sent through UDP, since it has the inherent possibility of losing messages or messing up the order - TCP is used so much in lots of other network applications.
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
|
Back to top
|
|
 |
blue hell
Former site admin

Joined: Apr 03, 2004 Posts: 24864 Location: The Netherlands, Enschede
Audio files: 353
G2 patch files: 320
|
Posted: Wed Feb 25, 2009 4:30 pm Post subject:
|
 |
|
| TCP usually uses an efficiency algorithm (Nagle) that you'd want to turn off for musical applications as it can cause delays of a couple of hundreds of milli seconds. But the good news is that it's easy for a programmer to turn it off, and likely this has been done already in music applications using TCP. |
|
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Thu Feb 26, 2009 6:47 am Post subject:
|
 |
|
| And so now if i'm using only localhost, why can't i send OSC messages from ChucK to SwingOSC if I run the SwingOSC TCP? I don't know much about networking, but it's just right on the same machine.. Or how do I make chuck send the OSC Message with TCP? |
|
|
Back to top
|
|
 |
Antimon

Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 373
G2 patch files: 100
|
Posted: Thu Feb 26, 2009 7:18 am Post subject:
|
 |
|
| kijjaz wrote: | | And so now if i'm using only localhost, why can't i send OSC messages from ChucK to SwingOSC if I run the SwingOSC TCP? I don't know much about networking, but it's just right on the same machine.. Or how do I make chuck send the OSC Message with TCP? |
Did you try connecting to the IP 127.0.0.1 instead of the name localhost?
It isn't always a straightforward thing to implement loopback, I've seen some pretty weird stuff when working on a custom platform...
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
|
Back to top
|
|
 |
|