Loading...
Logo
Processing Forum
Hello,

I am new to processing but I am familiar with programming languages/enviroments such as max/msp and supercollider.
I want to receive osc messages on processing from max msp. I have downloaded the oscp5 library and I can see the data I am sending from max to processing. Now the question is...how can I use the integers,floats whatever that I am receiving as values of variables in processing.

To make myself clear enough, how can for instance draw a rect that has for a coordinate an osc integer that I am receiving from max?

thanks in advance,
t

Replies(5)

Like this sketch :
Copy code
  1. import oscP5.*;
  2. import netP5.*;

  3. OscP5 oscP5;
  4. int x, y;

  5. void setup() {
  6.   size(400, 400);
  7.   oscP5 = new OscP5(this, 12001);
  8. }

  9. void draw() {
  10.   background(255);
  11.   rect(x, y, 100, 100);
  12. }

  13. void oscEvent(OscMessage theOscMessage) {
  14.   if (theOscMessage.addrPattern().equals("/adress")) {
  15.     x = theOscMessage.get(0).intValue();
  16.     y = theOscMessage.get(1).intValue();
  17.   }
  18. }
hey,thanks for your quick response.

I checked your sketch however I only get one static rect wich doesn't obey on different x,y values that are being received. I added a print() to see if I still get the osc from max/msp and I get the different values however I can't use them as x,y values. I am pretty sure it has to do with my lack of knowledge in processing but i don't know what I am doing wrong...


plus when i am reading the different values I first get a [0] and then my value from max (on the screenshot that's the number 3). why this is happening? this might be the problem?


finally mushussu can you explain a little bit why are you using get(0) and get(1)?

thanks once again,
t
ok i've found the solution thanks for the help mushussu. I rushed into writing again and again on the forum. Your sketch was fine the only thing I had to do was to specify on max the word /adress