electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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
Chuck, Reactivision & OSC
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
emoc



Joined: Aug 24, 2006
Posts: 12
Location: France

PostPosted: Fri Sep 07, 2007 3:44 pm    Post subject: Chuck, Reactivision & OSC
Subject description: an attempt to use the reactable software
Reply with quote  Mark this post and the followings unread

Hi,

I'm trying to implement the reactivision TUIO/OSC receiver for ChucK.

Reactivision is the open-source software behind reactable. It runs a communication protocol based on OSC called TUIO (tangible user interface..., ). A "Tuio simulator" (java applet) helps debugging. This simulator is already a nice interface : each object can be rotated & moved and physics data are transmited through TUIO / OSC

reactable : http://mtg.upf.edu/reactable/
TUIO http://modin.yuri.at/publications/tuio_gw2005.pdf
TUIO simulator http://mtg.upf.edu/reactable/?software

Posted Image, might have been reduced in size. Click Image to view fullscreen.

To fully implement, the receiver must catch three different message : alive, set, and fseq. 'set' and 'fseq' are predefined formats but alive changes with how much objects are on the table. 'set' messages are the most important because they carry physics data (motion, position) and you can already have fun with it! (and the script below)

Code:
/tuio/[profileName] set sessionID [parameterList]
/tuio/[profileName] alive [list of active sessionIDs]
/tuio/[profileName] fseq int32


The script chuck below catch 'set' & 'fseq' messages, but to catch 'alive' messages, you'll need flexible pattern matching, if there's any way to do it with ChucK ???
A dirty hack & code nightmare could be to add as much osc receivers as objects on the table each trying to catch one more integer...

Code:
// 7 sept. 2007 / chuck 1.2.1.0 /

// nom de l'hote et port par défaut
"localhost" => string hostName;
3333 => int receiverPort;

<<< "port de reception pour les messages OSC:", receiverPort >>>;

// objet OSC pour la réception
OscRecv receiver;
receiverPort => receiver.port;
// commencer l'écoute sur le port
receiver.listen();

// créer une adresse réceptrice des messages, y stocker la valeur de fréquence reçue
receiver.event( "/tuio/2Dobj,s,i,i,f,f,f,f,f,f,f,f" ) @=> OscEvent oeset;
receiver.event( "/tuio/2Dobj,s,i" ) @=> OscEvent oe1;


string a_type; int a_sessionid; int a_fiducialid; float a_xcoord; float a_ycoord;
float a_angle; float a_xmov; float a_ymov; float a_rotation;
float a_movaccel; float a_rotaccel; int frame_id; int nb;



fun void oesetListener() {

  while ( true ) {
    
    oeset => now;                    // en attente de l'arrivée d'un message OSC
   
    // capturer le nouveau message
    while ( oeset.nextMsg() != 0 ) {

      oeset.getString() => a_type;        // = set                        string
      oeset.getInt()    => a_sessionid;  // session ID, temporary ID,    int32
      oeset.getInt()    => a_fiducialid; // fiducial ID number,          int32
      oeset.getFloat()  => a_xcoord;     // position, range 0..1,        float32
      oeset.getFloat()  => a_ycoord;     // position, range 0..1,        float32
      oeset.getFloat()  => a_angle;      // angle, range 0..2PI,         float32
      oeset.getFloat()  => a_xmov;       // movement vector,             float32
      oeset.getFloat()  => a_ymov;       // movement vector,             float32
      oeset.getFloat()  => a_rotation;   // roration vector,             float32
      oeset.getFloat()  => a_movaccel;   // motion acceleration,         float32
      oeset.getFloat()  => a_rotaccel;   // rotation acceleration,       float32
   
      <<<"set : ", a_sessionid, a_fiducialid, a_xcoord, a_ycoord,
          a_angle, a_xmov, a_ymov, a_rotation, a_movaccel, a_rotaccel>>>;
    }
  }
}

spork ~ oesetListener();

fun void oe1Listener() {
  while ( true ) {
    oe1 => now;                  // en attente de l'arrivée d'un message OSC   
    while ( oe1.nextMsg() != 0 ) {    // capturer le nouveau message 
        oe1.getString() => a_type;        // = fseq || alive              string
      oe1.getInt()    => nb;             // frame ID || object sessionID,int32
      <<<a_type, " : ", nb>>>;
    }
  }
}

spork ~ oe1Listener();

while (true) {
  0.5::second => now;
}


_________________
codelab.fr
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Sep 07, 2007 7:36 pm    Post subject: Re: Chuck, Reactivision & OSC
Subject description: an attempt to use the reactable software
Reply with quote  Mark this post and the followings unread

emoc wrote:

The script chuck below catch 'set' & 'fseq' messages, but to catch 'alive' messages, you'll need flexible pattern matching, if there's any way to do it with ChucK ???
A dirty hack & code nightmare could be to add as much osc receivers as objects on the table each trying to catch one more integer...


Hmmm, A good first step might be one OSC receiver that would parse OSC, then send ChucK events for the different shreds? That would at least save the OSC receivers. I'm not sure wether you can make a array of events but that would be a possible solution.... You could just make a array of those that's longer then the amount of blocks that you have and asign one to each shred as you start it. I don't think unused events have any real overhead that matters.

Disclaimer; it's 4:30 here and I haven't thought this through.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
emoc



Joined: Aug 24, 2006
Posts: 12
Location: France

PostPosted: Tue Sep 11, 2007 2:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks Kassen for your answer,
I don't know how to do this global receiver. So, I'll make as many OSC receivers as necessary to update a big array containing parameters from reactivision markers. Other shreds will get data there to do what they have to do!

_________________
codelab.fr
Back to top
View user's profile Send private message Visit poster's website
emoc



Joined: Aug 24, 2006
Posts: 12
Location: France

PostPosted: Thu Apr 22, 2010 7:36 am    Post subject: Reply with quote  Mark this post and the followings unread

Hello,

It's a rather old thread, but for those interested, there's a TUIO class for chuck by Vilson Vieira : http://vilson.void.cc/wiki/forums.html?n=Main.ChuckTUIO

_________________
codelab.fr
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 [4 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


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use