We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Processing and Pure Data
Page Index Toggle Pages: 1
Processing and Pure Data (Read 9016 times)
Processing and Pure Data
Oct 4th, 2006, 11:08pm
 
Hey!!

I want to connect Processing with Pure Data to launch some oscillators. Could somebody tell me which is the best way to connect both programs?.

Thank you
Re: Processing and Pure Data
Reply #1 - Oct 5th, 2006, 12:35am
 
You can communicate between processing and pure data using osc. Check sojamos oscp5 lib at the library section. In pure-date you have to use oscx.
Re: Processing and Pure Data
Reply #2 - Oct 5th, 2006, 12:59am
 
hi,
i uploaded a processing sketch and a pd patch to http://www.sojamo.de/files/archive/oscP5andPD.zip to get you started with communicating between processing and pd.

andi
where is the osc for pd library
Reply #3 - Oct 5th, 2006, 4:37pm
 
hello,

i installed your library and am eager to try, but: where can i get the osc library for pd? the link in the pd download wiki http://www.puredata.org/community/pdwiki/OpenSoundControl/view?searchterm=osc is outdated. i could not find any other source.

thanks

wettermann
Re: Processing and Pure Data
Reply #4 - Oct 5th, 2006, 8:26pm
 
hi,
if you go to http://www.puredata.org/downloads and download the pd-extended version, the pd osc package is already include. on windows, there is a .reg file in the pd folder which you would have to execute once and then (re)start pd. on osx this is done automatically. then you should be set and ready to communicate between processing and pd.

andi
Re: Processing and Pure Data
Reply #5 - Oct 6th, 2006, 1:18am
 
Hi


  I already downloaded Pd extended version, but when I open the file oscPDtest.pd.....

sendOSC
... couldn't create
OSCroute /test
... couldn't create
dumpOSC 12001
... couldn't create
error: unpack: i: bad type
error: unpack: i: bad type
error: pack: i: bad type
error: pack: i: bad type
error: pack: i: bad type

     Do I have to do something else like create an object before I open the file like in gem??
Re: Processing and Pure Data
Reply #6 - Oct 6th, 2006, 9:47pm
 
hi,
first you need to open pd without double-clicking the oscPDtest.pd file, but the actual pd application. after pd has loaded properly, open (either menu or by doubleclicking) the oscPDtest.pd file and click the connect button in the patch - in the output window it should say
connected to port 127.0.0.1:12000
the issue with the i can be fixed by changing the i in the pack and unpack object to f . but it will also work if you keep the i.

andi

Re: Processing and Pure Data
Reply #7 - Oct 12th, 2006, 2:50pm
 
- - - - - - -
| dumpOSC |              couldn't create
- - - - - - -
       \                                                    
- - - - - - - - -
|OSCroute /test |         couldn't create
- - - - - - - - -
        - - - - -
       |sendOSC|             couldn't create
        - - - - -              


       I have PD extended installed and the osc objects can't be created i did what you told me and doesn't work, is there something wrong with oscx library or I am missing some steps. In processing oscP5 works perfect.


Thanks
Re: Processing and Pure Data
Reply #8 - Oct 12th, 2006, 6:02pm
 
hi,
i am using Pd version 0.38.4-extended-RC8 on osx and oscx works for me. you can check if osx is part of your pd release by taking a look at its package contents (ctrl + click on the pd application -> show package contents) then in folder Contents/Resources/extra there should be a folder called oscx with dumpOSC.pd_darwin, OSCroute.pd_darwin and sendOSC.pd_darwin in it.

you can also take a look at http://at.or.at/hans/pd/installers.html and http://at.or.at/hans/pd/objects.html where you can find OSC for Mac os x at the bottom of the page.

you can also check the plist in your home directory/Library/Preferences/org.puredata.pd.plist if the oscx library is included in the loadlib dictinary. mine says:
<key>loadlib16</key>
<string>oscx</string>

if it still wont work, then it might be a question for the forums at puredata.org

hope this helps,
andi
Re: Processing and Pure Data
Reply #9 - Oct 24th, 2006, 6:04pm
 
thank you for this code Andreas, it's exactly what i was looking for.
By the way, i've some little problems: for example, the osc messages are used to change the colour of the rectangle with this string

void test(int theR, int theG, int theB) {
 fill(theR,theG,theB);  
}

i'd like to route the parameters to the dimension of the rectangle like
rect(0,0,theR,theB);

it is possibile to do that?
i've tried with

void draw() {
 background(0);
 noStroke();
 test(int rx, int ry, int rz);
 rect(0,0,rx,ry);

but doesn't works...

sorry for this newbie question and thanks for help and oscP5
Re: Processing and Pure Data
Reply #10 - Oct 25th, 2006, 11:17am
 
hi,
the best thing to do would be to have 2 variables defined in your porcessing code that contain the width and height of your rect you want to control.
so when you get an osc message with address pattern /test that includes the parameters to change the dimensions of your rect, you would need to parse this message and set the variables in your code to the correspondent values of the osc message. see code below as an example.
Code:

import oscP5.*;

int myRectWidth = 10;
int myRectHeight = 10;
OscP5 oscP5;

void setup() {
/* start oscP5 and listen for incoming messages at port 12000*/
oscP5 = new OscP5(this,12000);
}

void draw() {
background(0);
fill(255,0,0);
rect(0,0,myRectWidth,myRectHeight);
}


void oscEvent(OscMessage theOscMessage) {
if(theOscMessage.checkAddrPattern("/test")) {
/* got a /test message */
if(theOscMessage.checkTypetag("ii")) {
/* the typetag of the /test message is ii.
so lets update the rect dimensions
*/
myRectWidth = theOscMessage.get(0).intValue();
myRectHeight = theOscMessage.get(1).intValue();
}
}
}
Re: Processing and Pure Data
Reply #11 - Oct 25th, 2006, 7:23pm
 
thank you very much andi, now all works fine!
Re: Processing and Pure Data
Reply #12 - Apr 13th, 2010, 6:23pm
 
what should i fill in place of that?
NetAddress myRemoteLocation;

!
Re: Processing and Pure Data
Reply #13 - Apr 15th, 2010, 3:04pm
 
Hello,

ı'm using your OSCP5test.pde and OSCPDtest.pd
the pd file seems working.
when ı click on connect it print:
sendOSC: connected to port 127.0.0.1:12000 (hSock=21214096) protocol = UDP

but the pde is not working.
it's saying:
cannot find a class or type named "NetAdress".

is there something ım missing?

thanlks.
Re: Processing and Pure Data
Reply #14 - Apr 15th, 2010, 4:07pm
 
ok it worked with this code

/**
* 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;

void setup() {
 size(400,400);
 frameRate(25);
 /* start oscP5, listening for incoming messages at port 12000 */
 oscP5 = new OscP5(this,12000);
 
 /* 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",12001);
}


void draw() {
 background(0);  
}

void mousePressed() {
 /* in the following different ways of creating osc messages are shown by example */
 OscMessage myMessage = new OscMessage("/test");
 
 myMessage.add(123); /* add an int to the osc message */

 /* 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());
}
Page Index Toggle Pages: 1