I want use Pure Data as GUI for an appli­ca­tion. I wrote a lit­tle PD patch which send and receive data via tcp con­nec­tions. I use Pro­cess­ing to get this mes­sages (PD use a mes­sage for­mat called FUDI).

The Pure Data patch looks like this:


The Out­puts and Effects num­ber boxes gets updates if the Pro­cess­ing sketch send data. I added also an “autoup­date” func­tion, press the tog­gle and the patch sends each 1000ms a STATUS mes­sage to the Pro­cess­ing sketch.

 
The Pro­cess­ing Sketch looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import processing.net.*;

Server tcpServer=null;
Client client;
int i=0;

void setup()
{
  tcpServer = new Server(this, 3443);
  client = new Client(this, “127.0.0.1″, 3445);
  frameRate(5);
}

void draw()
{
  if (tcpServer!=null) {
    Client c = tcpServer.available();
    while (c!=null && c.available()>0) {
      //get mes­sage from Pure Data
      String msg = c.readString().trim();
      println(“got msg: “+msg);
     
      if (msg.equalsIgnoreCase(“STATUS;”)) {
        //send mes­sage to Pure Data
        client.write(“hello from pro­cess­ing;”);
        client.write(“OUTPUTS “+i+”;”);
        client.write(“EFFECTS 3;”);        
        i++;
      }
    }
  }
}

Now the Pure Data patch can com­mu­ni­cate with the Pro­cess­ing sketch.