| Author |
Message |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 135 Location: Cambridge
Audio files: 1
|
Posted: Fri Mar 28, 2008 6:37 pm Post subject:
Receiving more than one integer or float at once using OSC.. |
 |
|
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
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 798 Location: Florida, USA
Audio files: 37
|
|
|
Back to top
|
|
 |
soundcyst
Joined: Feb 17, 2008 Posts: 17 Location: santa cruz, ca
|
Posted: Sat Mar 29, 2008 2:08 pm Post subject:
Re: Receiving more than one integer or float at once using O |
 |
|
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
|
|
 |
soundcyst
Joined: Feb 17, 2008 Posts: 17 Location: santa cruz, ca
|
Posted: Sat Mar 29, 2008 2:15 pm Post subject:
|
 |
|
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
|
|
 |
sanch
Joined: Mar 23, 2008 Posts: 3 Location: somewhere
|
Posted: Sat Mar 29, 2008 8:57 pm Post subject:
|
 |
|
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
|
|
 |
Dr. Spankenstein
Joined: Mar 03, 2007 Posts: 135 Location: Cambridge
Audio files: 1
|
Posted: Sun Mar 30, 2008 5:28 am Post subject:
|
 |
|
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
|
|
 |
|