Receiving numbers from Pure Data via OSC

Hi,

I built a patch in Pure Data to send numbers via OSC:

OSC1

and I verified that the numbers were received (in the Pure Data console, not in Processing), and they are received correctly.

Now, what is the way to receive these numbers in Processing, into a variable x?
For example into the “x” in this Processing code:

size (600, 600);
strokeWeight(2);
point(x, 50);
strokeWeight(1);//reset

What I would expect is that as I vary the numbers in Pure Data, I should see the point move along the x-axis in Processing.
Thank you,
f

Here is probably the solution:
(YouTube tutorial video)

Trying to run the code (taken from the tutorial I posted above), it gives me this error:

myRemoteLocation cannot be resolved to a variable

error

Does anyone know what causes this?
[I use Processing 4.3 on Linux]

Thank you,
f

You missed some of the code.

Install the library and explore the working examples that come with it:

:)

How do you know that some code is missing if you can only see a screenshot of a detail?
This is the entire code, which I transcribed from the tutorial:

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocaton;
float circleSize;

void setup() {
 size(400,400);
 frameRate(25);
 oscP5 = new OscP5(this,12000);
 
 myRemoteLocation = new NetAddress("127.0.0.1",12000);
 
 circlesize = 10;
}
 
void draw() {
 background(0);
 ellipse(width/2, height/2, circleSize, circleSize);
}

void mouseMoved() {
 OscMessage myMessage = new OscMessage("/puredata");
 
 myMessage.add(mouseX); /* add an int to the osc message */
 
 /* send the message */
 oscP5.send(myMessage, myRemoteLocation);
}

/* incoming OSC message are forwarded to oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
 /* print the address pattern and the typetag of the received OscMessage */
 print("### received an osc message.");
 print(" addrpattern: "+theOscMessage.addrPattern());
 println(" typetag: "+theOscMessage.typetag());
 println(" arguments: " + theOscMessage.get(0).intValue());
 
 circleSize = theOscMessage.get(0).intValue();
}

I see at least two transcription errors that are generating an error.

Compare the code above setup() to that in setup();

:)

2 Likes

Ok, there were 2 typos:
circlesize → circleSize
myRemoteLocaton → myRemoteLocation

Now it works.
Thanks,
f

2 Likes