Hello processing world! (this is my first post here)
I have a problem with the OSC reciever of oscP5 library. I can see the messges I'm receiving from SuperCollider. I can set variables in processig. Also I can send back the recieved messages. But unfortunetly I can not draw anything with that messages. I tried 4 different methods and still nothing. Please some help!
Thanks a lot..!
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
NetAddress superCollider;
void setup() {
size(700, 500);
background(0);
oscP5 = new OscP5(this, 12000);
myRemoteLocation = new NetAddress("127.0.0.2", 12000);
superCollider = new NetAddress("192.168.1.4", 57120);
oscP5.plug(this, "test3", "/test3");
}
void draw() {
}
void mousePressed() {
fill(250);
rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
}
void oscEvent(OscMessage theOscMessage) {
/* check if theOscMessage has the address pattern we are looking for. */
if (theOscMessage.checkAddrPattern("/test")==true) {
/* check if the typetag is the right one. */
if (theOscMessage.checkTypetag("ii")) {
/* parse theOscMessage and extract the values from the osc message arguments. */
int val01 = theOscMessage.get(0).intValue(); // get the first osc argument
int val02 = theOscMessage.get(1).intValue(); // get the second osc argument
fill(250);
rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
OscMessage myMessage = new OscMessage("/testBack");
myMessage.add(val01); /* add an int to the osc message */
myMessage.add(val02);
oscP5.send(myMessage, superCollider);
}
}
/* check if theOscMessage has the address pattern we are looking for. */
String addr = theOscMessage.addrPattern();
int val0 = theOscMessage.get(0).intValue();
if (addr.equals("/test2")) {
fill(250);
rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
}
if (theOscMessage.checkAddrPattern("/test4")==true) {
/* parse theOscMessage and extract the values from the osc message arguments. */
int val01 = theOscMessage.get(0).intValue(); // get the first osc argument
int val02 = theOscMessage.get(1).intValue(); // get the second osc argument
fill(150);
ellipse(20, 20, 50, 50);
OscMessage myMessage = new OscMessage("/testBack4");
myMessage.add(val01); /* add an int to the osc message */
myMessage.add(val02);
oscP5.send(myMessage, superCollider);
}
}
public void test3(int theA, int theB) {
println("### plug event method. received a message /test3.");
println(" 2 ints received: " +theA+ ", " +theB);
fill(250);
rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
}