# Receiving numbers from Pure Data via OSC

**URL:** <https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786>\
**Category:** Libraries\
**Created:** [July 19, 2024, 12:41pm UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786 "2024-07-19T12:41:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 19, 2024, 12:41pm UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/1 "2024-07-19T12:41:50Z")

</div>

Hi,

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

![OSC1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/3/93fe0e611b18ea3f0a9fbc7d0fa087e2bc760d52.png)

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 20, 2024, 10:26am UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/2 "2024-07-20T10:26:34Z")

</div>

Here is probably the solution:  
(YouTube tutorial video)

[![](https://img.youtube.com/vi/TTd57stEr_g/maxresdefault.jpg "Pure Data Part 4: Open Sound Control") ](https://www.youtube.com/watch?v=TTd57stEr_g)

---

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 20, 2024, 11:53am UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/3 "2024-07-20T11:53:19Z")

</div>

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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/5/f5d886416323419ebf98250a4f13773589405b13.png)

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

Thank you,  
f

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 20, 2024, 12:33pm UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/4 "2024-07-20T12:33:10Z")

</div>

> [@fra](#):
>
> Trying to run the code (taken from the tutorial I posted above)

> [@fra](#):
>
> Does anyone know what causes this?

You missed some of the code.

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

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/4/4445670f3e31005bb4ba5b518702235a177db076.png)

`:)`

---

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 20, 2024, 5:12pm UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/5 "2024-07-20T17:12:36Z")

</div>

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:

```auto
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();
}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 20, 2024, 5:38pm UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/6 "2024-07-20T17:38:22Z")

</div>

> [@fra](#):
>
> This is the entire code, which I transcribed from the tutorial:

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

Compare the code above _setup()_ to that in _setup();_

`:)`

---

<div class="post-metadata">

**Author:** ![fra](https://avatars.discourse-cdn.com/v4/letter/f/a6a055/32.png) [@fra](https://discourse.processing.org/u/fra)\
**Post date:** [July 20, 2024, 5:55pm UTC](https://discourse.processing.org/t/receiving-numbers-from-pure-data-via-osc/44786/7 "2024-07-20T17:55:15Z")

</div>

> [@glv](#):
>
> I see at least two transcription errors

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

Now it works.  
Thanks,  
f
