# Processing Max Msp. Sending data to Max

**URL:** <https://discourse.processing.org/t/processing-max-msp-sending-data-to-max/18987>\
**Category:** Libraries\
**Created:** [March 24, 2020, 4:12pm UTC](https://discourse.processing.org/t/processing-max-msp-sending-data-to-max/18987 "2020-03-24T16:12:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [March 24, 2020, 4:12pm UTC](https://discourse.processing.org/t/processing-max-msp-sending-data-to-max/18987/1 "2020-03-24T16:12:27Z")

</div>

Hello guys!

I would like to send data to max (float and int).  
I made a small sketch based on the example of the library oscP5, but I don’t know at all, if we can send several int like that. There is a problem with floats.

I read this in the monitor, I’m not sure it a good sign.

> [2020/3/24 17:31:17] PROCESS @ OscP5 stopped.  
> [2020/3/24 17:31:17] PROCESS @ UdpClient.openSocket udp socket initialized.  
> [2020/3/24 17:31:18] ERROR @ UdpServer.start() IOException, couldnt create new DatagramSocket @ port 12000 java.net.BindException: Address already in use (Bind failed)  
> [2020/3/24 17:31:23] INFO @ OscP5 is running. you (192.168.1.105) are listening @ port 12000

I will put the patch of Max Msp later.

Thank you to all !

```auto
/**
 * oscP5sendreceive by andreas schlegel
 * example shows how to send and receive osc messages.
 * oscP5 website at http://www.sojamo.de/oscP5
 */
 
import oscP5.*;
import netP5.*;
  
OscP5 oscP5;
NetAddress myRemoteLocation;

float speedA, speedB, speedC, speedD, speedE;
int numberofrevolutionA, numberofrevolutionB, numberofrevolutionC, numberofrevolutionD, numberofrevolutionE;

void setup() {
  size(400,400);
  frameRate(25);
  /* start oscP5, listening for incoming messages at port 12000 */
  oscP5 = new OscP5(this,12000);
      speedA=0.01;
      speedB=0.02;
      speedC=0.03;
      speedD=0.04;
      speedE=0.05;
  
      numberofrevolutionA =0;
     numberofrevolutionB =1;
     numberofrevolutionC =2;
     numberofrevolutionD =3;
     numberofrevolutionE =4;
    
  
  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
   * an ip address and a port number. myRemoteLocation is used as parameter in
   * oscP5.send() when sending osc packets to another computer, device, 
   * application. usage see below. for testing purposes the listening port
   * and the port of the remote location address are the same, hence you will
   * send messages back to this sketch.
   */
 // myRemoteLocation = new NetAddress("127.0.0.1",12000);
}

void draw() {
  background(0);  
}

void mousePressed() {
  
 
  
  numberofrevolutionA = numberofrevolutionA+1; numberofrevolutionB = numberofrevolutionB+1; numberofrevolutionC = numberofrevolutionC+1;
  speedA=speedA+0.01; speedB=speedB+0.01; speedC=speedC+0.01;
   
  /* in the following different ways of creating osc messages are shown by example */
  OscMessage myMessage = new OscMessage("/test");
  
  println (numberofrevolutionA, numberofrevolutionB, numberofrevolutionC );
  println (speedA, speedB, speedC);
  
  myMessage.add(numberofrevolutionA, numberofrevolutionA, numberofrevolutionB, numberofrevolutionC ); /* add an int to the osc message */
 // myMessage.add(speedA, speedB, speedC);
  
  

  /* send the message */
 // oscP5.send(myMessage, myRemoteLocation); 
}

/* incoming osc message are forwarded to the 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());
}

```

```auto
/**
 * oscP5sendreceive by andreas schlegel
 * example shows how to send and receive osc messages.
 * oscP5 website at http://www.sojamo.de/oscP5
 */
 
import oscP5.*;
import netP5.*;
  
OscP5 oscP5;
NetAddress myRemoteLocation;

float speedA, speedB, speedC, speedD, speedE;
int numberofrevolutionA, numberofrevolutionB, numberofrevolutionC, numberofrevolutionD, numberofrevolutionE;

void setup() {
  size(400,400);
  frameRate(25);
  /* start oscP5, listening for incoming messages at port 12000 */
  oscP5 = new OscP5(this,12000);
      speedA=0.01;
      speedB=0.02;
      speedC=0.03;
      speedD=0.04;
      speedE=0.05;
  
      numberofrevolutionA =0;
     numberofrevolutionB =1;
     numberofrevolutionC =2;
     numberofrevolutionD =3;
     numberofrevolutionE =4;
    
  
  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
   * an ip address and a port number. myRemoteLocation is used as parameter in
   * oscP5.send() when sending osc packets to another computer, device, 
   * application. usage see below. for testing purposes the listening port
   * and the port of the remote location address are the same, hence you will
   * send messages back to this sketch.
   */
 // myRemoteLocation = new NetAddress("127.0.0.1",12000);
}

void draw() {
  background(0);  
}

void mousePressed() {
  
 
  
  numberofrevolutionA = numberofrevolutionA+1; numberofrevolutionB = numberofrevolutionB+1; numberofrevolutionC = numberofrevolutionC+1;
  speedA=speedA+0.01; speedB=speedB+0.01; speedC=speedC+0.01;
   
  /* in the following different ways of creating osc messages are shown by example */
  OscMessage myMessage = new OscMessage("/test");
  
  println (numberofrevolutionA, numberofrevolutionB, numberofrevolutionC );
  println (speedA, speedB, speedC);
  
  myMessage.add(numberofrevolutionA, numberofrevolutionA, numberofrevolutionB, numberofrevolutionC ); /* add an int to the osc message */
 // myMessage.add(speedA, speedB, speedC);
  
  

  /* send the message */
 // oscP5.send(myMessage, myRemoteLocation); 
}

/* incoming osc message are forwarded to the 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());
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 29, 2020, 4:57pm UTC](https://discourse.processing.org/t/processing-max-msp-sending-data-to-max/18987/2 "2020-03-29T16:57:02Z")

</div>

@bking Were you able to resolve this issue?

---

<div class="post-metadata">

**Author:** ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)\
**Post date:** [March 29, 2020, 7:32pm UTC](https://discourse.processing.org/t/processing-max-msp-sending-data-to-max/18987/3 "2020-03-29T19:32:19Z")

</div>

Yes and no.

I haven’t really tried to send data directly from Processing to Max.  
But, as I succeeded in sending data from Processing to Arduino and Arduino to Max, I tried to send data this way. I had a small bug, but it seems easily doable. 😀 😊 😇  
But since my lovely and charming daughter spilled sweet milk on my MacBookPro , I can’t show you the solution right now. I will do it ASAP.  
But the direct solution, Processing to Max, interests me just to compare the fluidity of sending and receiving data between Processing and Max.  
In fact, I don’t know if it’s useful to think about this direct solution.  
In the end, I should send to Max Msp, 10 speed data, 10 position data (between 0 and 2PI) and 10 data informing of the number of revolutions that my virtual engines make, then send this data from Max4live to Abelton Live. (a patch max/msp transformed to be red directly in Ableton Live).  
I already managed to do this with 5 information of speeds and number of laps, but I had small bugs in Live because I had sent too much MIDI information coming from Max Msp, or sent too quickly. 🤔

To settle this, I bought a 15 inch quad core i7, 16 GB macbook from Ram, hoping that Ableton Live will work better. I had a macBook 13.3 from 2014.

Thank you for all your advice and all the solutions you have already given me;) 🥰

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 29, 2020, 7:47pm UTC](https://discourse.processing.org/t/processing-max-msp-sending-data-to-max/18987/4 "2020-03-29T19:47:38Z")

</div>

Some past Max-Processing libraries that might be of interest. They generally build on using oscP5 / OSC. I’d suggest looking at the most recent ones first (newest first, oldest is last)

> **[siteswapjuggler/myo\_bridge](https://github.com/siteswapjuggler/myo_bridge)**
>
> Myo processing to max bridge. Contribute to siteswapjuggler/myo\_bridge development by creating an account on GitHub.

> **[hendrikleper/max-processing-max](https://github.com/hendrikleper/max-processing-max)**
>
> bridging MAX & PROCESSING with OSC . Contribute to hendrikleper/max-processing-max development by creating an account on GitHub.

> **[markmarijnissen/processing-for-max-and-matlab](https://github.com/markmarijnissen/processing-for-max-and-matlab)**
>
> Use Processing in Max/MSP or Matlab. Contribute to markmarijnissen/processing-for-max-and-matlab development by creating an account on GitHub.

> **[jkriss/maxlink](https://github.com/jkriss/maxlink)**
>
> A library that gets Max/MSP and Processing talking to each other - jkriss/maxlink
