electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 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
Receiving more than one integer or float at once using OSC..
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Dr. Spankenstein



Joined: Mar 03, 2007
Posts: 135
Location: Cambridge
Audio files: 1

PostPosted: Fri Mar 28, 2008 6:37 pm    Post subject: Receiving more than one integer or float at once using OSC.. Reply with quote  Mark this post and the followings unread

I was thinking, rather than sending a whole load of data on various different ports via OSC at the same time wouldn't it be safer to collect the numerical data in a list and then send that via one port as a long OSC message to ChucK?

If it is better than the lost of one variable messages at a time on different port method, how would I go about retreiving the information from a list?

Code:


OscRecv recv;
6448 => recv.port;
recv.listen();
recv.event("/a, i i i i i i i i i" ) @=> OscEvent oe;

while( true )
{
    oe => now;
    while( oe.nextMsg() )
    {
           int i;
       oe.getInt() => i;
           <<< "got (via OSC):", i>>>;
    }
}



For example my code above has nine possible integers but I am unsure how to get all the data into separate variables in ChucK?

I'm assuming this is a better road to go down as I have a lot of data to pass to ChucK very quickly and unless I have a latency of around 10ms then ChucK crashes when it comes to receiving the data, even though it is told to wait on the incoming data before progressing.

I hope that made sense,

Rhys
Back to top
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 828
Location: Florida, USA
Audio files: 37

PostPosted: Fri Mar 28, 2008 7:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

Does this recent post help?

http://electro-music.com/forum/topic-25052.html

Sorry, but I don't know much about this...

_________________
@(ºoº)@ ><}}}º> ~(^.^) <:3 )~
Back to top
View user's profile Send private message Send e-mail Visit poster's website
soundcyst



Joined: Feb 17, 2008
Posts: 17
Location: santa cruz, ca

PostPosted: Sat Mar 29, 2008 2:08 pm    Post subject: Re: Receiving more than one integer or float at once using O Reply with quote  Mark this post and the followings unread

i think you can just keep piling up oe.getInt()s like this:

OscRecv recv;
6448 => recv.port;
recv.listen();
recv.event("/a, i i i i i i i i i" ) @=> OscEvent oe;

Code:

while( true )
{
    oe => now;
    while( oe.nextMsg() )
    {
        int i[9];
        for (int j = 0; j<10> i[j];
            <<< "got (via OSC):", i[j]>>>;
        }
    }
}


i know that when i code for the monome, we do this to get all 3 button press values.

Code:
while ( oe.nextMsg() != 0 )
   {
      oe.getInt() => x;   
      oe.getInt() => y;
      oe.getInt() => state;

      //etc...
   }
Back to top
View user's profile Send private message
soundcyst



Joined: Feb 17, 2008
Posts: 17
Location: santa cruz, ca

PostPosted: Sat Mar 29, 2008 2:15 pm    Post subject: Reply with quote  Mark this post and the followings unread

i have no idea why the code parameter isn't working

it's supposed to be a for loop

Code:

for (int j = 0; j [less than] 10; j++ ) {
    oe.getInt() => i[j];
    ///your printing stuff
}
Back to top
View user's profile Send private message
sanch



Joined: Mar 23, 2008
Posts: 3
Location: somewhere

PostPosted: Sat Mar 29, 2008 8:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

For me the array size is dynamic that way :
The technic with to create the string type create a memory leak...
the code should works
actually i would like to make it all dynamic and inside a class , but it´s more complicate than i thought for a newbie like me.

Code:

50 => int max; //max array size
float data[max];
 //array to store data from v4


"f" => string type;//"f" => string type; 
"localhost" => string hostName;//"localhost" => string hostName;
8050 =>int receiverPort; //6574 => int receiverPort;


"" => string ftype;
"" => string save;

for(0 => int i ; i < max ; i++){  //generate type string
if (i == 0)type  => save;
else ","+ type  => save;
ftype + save => ftype;
}
<<<ftype>>>;


OscRecv receiver;// objet OSC pour la réception
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( "/1" ,ftype ) @=> OscEvent oe;


fun  float[] oeListener() {
 
      oe => now;                   // en attente de l'arrivée d'un message OSC
      while ( oe.nextMsg() != 0 )  // capturer les nouveaux messages
      { 
      for(0 => int i ; i < max ; i++)
      {
     <<< oe.getFloat() @=> data[i]>>>;
 
      }
      return data;
   
  }
}

while (true) {

      oeListener() @=>  data;
       
     for(0 => int i; i < max ; i++) <<<data[i]>>>;
     
 
}
[/quote]
Back to top
View user's profile Send private message
Dr. Spankenstein



Joined: Mar 03, 2007
Posts: 135
Location: Cambridge
Audio files: 1

PostPosted: Sun Mar 30, 2008 5:28 am    Post subject: Reply with quote  Mark this post and the followings unread

I've gone for the one message at a time method for the time being, as time isn't something I have a lot of now.

However I discovered the problem I was having with OSC is that I shouldn't try and send loads of data of separate ports. Sending it all over one port works perfectly though without crashing ChucK!

Rhys
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 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

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com