I want use Pure Data as GUI for an application. I wrote a little PD patch which send and receive data via tcp connections. I use Processing to get this messages (PD use a message format called FUDI).
The Pure Data patch looks like this:
The Outputs and Effects number boxes gets updates if the Processing sketch send data. I added also an “autoupdate” function, press the toggle and the patch sends each 1000ms a STATUS message to the Processing sketch.
The Processing 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 message from Pure Data String msg = c.readString().trim(); println(“got msg: “+msg); if (msg.equalsIgnoreCase(“STATUS;”)) { //send message to Pure Data client.write(“hello from processing;”); client.write(“OUTPUTS “+i+”;”); client.write(“EFFECTS 3;”); i++; } } } } |
Now the Pure Data patch can communicate with the Processing sketch.
One Comment
1 simon wrote:
Thanks!!!