oscP5
in
Contributed Library Questions
•
3 years ago
hi
I am having some troubles with receiving incoming values from OSC. I have a PD patch that sends out osc messages on port 9002. Mostly everything works but then if I try using oscMessage.get(0).floatValue() (or intValue etc) I get error:
### [2010/8/4 15:17:4] ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage to a method in your program. please check your code for any possible errors that might occur in the method where incoming OscMessages are parsed e.g. check for casting errors, possible nullpointers, array overflows ... .
So I have done a work around, converting the incoming value to a string & then converting that to a float. This works almost all the time, but intermittently despite my work around, I get the same error as above, and can't figure out why.
I also have a mouse press sending an osc message with the same format that the PD patch sends in. It seems to work fine.
There are really a lot of osc events coming in from the PD patch. Could it be the sheer volume causing this error?
Any help VERY MUCH appreciated
I am trying:
//IMPORTS
import oscP5.*;
import netP5.*;
//DECLARATIONS
OscP5 oscP5;
NetAddress myRemoteLocation;
String addrPatternIn, filterData;
String[]addrPattern_arr;
float incoming;
//SET UP
void setup() {
size(480, 270);
frameRate(20);
//start oscP5, listening for incoming messages at port 9002
oscP5 = new OscP5(this,9002);
// set remeote loaction as this computer while testing
myRemoteLocation = new NetAddress("127.0.0.1",9002);
//initial value for incoming
addrPatternIn = "";
incoming = -120.56;
}
//REPEAT
void draw() {
}
//EVENTS
void mousePressed() {
//mouse creates new osc message with random float number
OscMessage myMessage = new OscMessage("/assassins/blocker/abermarle/bump/sim");
float ranNum = random(60) - 30;
myMessage.add(ranNum);
println(myMessage);
//send the message - will be received by the oscEvent listener below
oscP5.send(myMessage, myRemoteLocation);
}
void oscEvent(OscMessage theOscMessage) {
//println(theOscMessage.get(0).floatValue()); // ***get() produces error
//println(theOscMessage.arguments()[0]);// this works ???@***
// println(" addrpattern: "+theOscMessage.addrPattern());
//println(" typetag: "+theOscMessage.typetag());
//println("value: " + theOscMessage.get(0).floatValue());//** doesn't work
//println(theOscMessage.get(0).toString());//** doesn't work
// ** this one WORKS** println(theOscMessage.arguments()[0].toString());
//theOscMessage.print();
//get whole address pattern of incoming osc
addrPatternIn = theOscMessage.addrPattern();
//find the 4th item - gyro filter, xyz or bump
addrPattern_arr = split(addrPatternIn, "/");
filterData = addrPattern_arr[4];
if(filterData.equals("bump") ) {
//theOscMessage.print();
println("*** BUMP ***********************");
String tempVal = theOscMessage.arguments()[0].toString();
incoming = float(tempVal);
println(incoming);
}
}
thanks
Linda
I am having some troubles with receiving incoming values from OSC. I have a PD patch that sends out osc messages on port 9002. Mostly everything works but then if I try using oscMessage.get(0).floatValue() (or intValue etc) I get error:
### [2010/8/4 15:17:4] ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage to a method in your program. please check your code for any possible errors that might occur in the method where incoming OscMessages are parsed e.g. check for casting errors, possible nullpointers, array overflows ... .
So I have done a work around, converting the incoming value to a string & then converting that to a float. This works almost all the time, but intermittently despite my work around, I get the same error as above, and can't figure out why.
I also have a mouse press sending an osc message with the same format that the PD patch sends in. It seems to work fine.
There are really a lot of osc events coming in from the PD patch. Could it be the sheer volume causing this error?
Any help VERY MUCH appreciated
I am trying:
//IMPORTS
import oscP5.*;
import netP5.*;
//DECLARATIONS
OscP5 oscP5;
NetAddress myRemoteLocation;
String addrPatternIn, filterData;
String[]addrPattern_arr;
float incoming;
//SET UP
void setup() {
size(480, 270);
frameRate(20);
//start oscP5, listening for incoming messages at port 9002
oscP5 = new OscP5(this,9002);
// set remeote loaction as this computer while testing
myRemoteLocation = new NetAddress("127.0.0.1",9002);
//initial value for incoming
addrPatternIn = "";
incoming = -120.56;
}
//REPEAT
void draw() {
}
//EVENTS
void mousePressed() {
//mouse creates new osc message with random float number
OscMessage myMessage = new OscMessage("/assassins/blocker/abermarle/bump/sim");
float ranNum = random(60) - 30;
myMessage.add(ranNum);
println(myMessage);
//send the message - will be received by the oscEvent listener below
oscP5.send(myMessage, myRemoteLocation);
}
void oscEvent(OscMessage theOscMessage) {
//println(theOscMessage.get(0).floatValue()); // ***get() produces error
//println(theOscMessage.arguments()[0]);// this works ???@***
// println(" addrpattern: "+theOscMessage.addrPattern());
//println(" typetag: "+theOscMessage.typetag());
//println("value: " + theOscMessage.get(0).floatValue());//** doesn't work
//println(theOscMessage.get(0).toString());//** doesn't work
// ** this one WORKS** println(theOscMessage.arguments()[0].toString());
//theOscMessage.print();
//get whole address pattern of incoming osc
addrPatternIn = theOscMessage.addrPattern();
//find the 4th item - gyro filter, xyz or bump
addrPattern_arr = split(addrPatternIn, "/");
filterData = addrPattern_arr[4];
if(filterData.equals("bump") ) {
//theOscMessage.print();
println("*** BUMP ***********************");
String tempVal = theOscMessage.arguments()[0].toString();
incoming = float(tempVal);
println(incoming);
}
}
thanks
Linda
5