electro-music.org   Dedicated to experimental electro-acoustic
and electronic music
 
 Front Page  |  Radio  |  Forum  |  Media  |  Playlists  |  Wiki
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Using ChucK with SwingOSC (for graphical interface)
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [12 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Mon Feb 23, 2009 11:16 pm    Post subject: Using ChucK with SwingOSC (for graphical interface) Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 270

PostPosted: Mon Feb 23, 2009 11:46 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Feb 24, 2009 12:00 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Feb 24, 2009 12:35 am    Post subject: Reply with quote  Mark this post and the followings unread

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:
Code:
pi : 3.14159


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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 270

PostPosted: Tue Feb 24, 2009 3:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Good, keep us posted kijjaz!
_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Tue Feb 24, 2009 8:44 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website AIM Address
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 373
G2 patch files: 100

PostPosted: Wed Feb 25, 2009 8:45 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
dewdrop_world



Joined: Aug 28, 2006
Posts: 858
Location: Guangzhou, China
Audio files: 4

PostPosted: Wed Feb 25, 2009 10:22 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website AIM Address
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 373
G2 patch files: 100

PostPosted: Wed Feb 25, 2009 10:57 am    Post subject: Reply with quote  Mark this post and the followings unread

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. Smile 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
View user's profile Send private message Visit poster's website
blue hell
Former site admin


Joined: Apr 03, 2004
Posts: 24864
Location: The Netherlands, Enschede
Audio files: 353
G2 patch files: 320

PostPosted: Wed Feb 25, 2009 4:30 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Feb 26, 2009 6:47 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 373
G2 patch files: 100

PostPosted: Thu Feb 26, 2009 7:18 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [12 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Log in
Username:     Password:      Log me on automatically each visit    


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2026 by electro-music.org