important: this post is old and the code can be out-of-date. use it at your own risk.
this post will explain how to extend Pd functionalities to other languages, allowing us to use it something like an API. with this, we could for example create a [osc~] and connect it to a [dac~] using for this just a python program. this is possible due to dynamic creation of Pd objects (aka dynamic patching) realized through sockets.
it’s important to notice that this is different from simple exchanging values of variables through sockets. if you want this, i advice you to take a look on netsend and netreceive objects.
to make things more clear, i’m going to use some examples. they can be found through svn at:
1. putting pd to work without gui
well… that’s it! this simple step makes Pd run without any gui. you can do this running pd in command line with -nogui parameter. to illustrate how we can use it, execute remote.pd file according the above. after it, just execute normally client.pd and see what happens.
this is important if you dont want to see any pd patch appearing on the screen during the execution of your non-pd program. if this doesn’t make sense to you, just skip this step.
2. dynamic creation of patchs and objects
this second step is about dynamic patching itself. it consists on sending messages to pd, that interpretes and tranfosms them into pd objects as soon they are sent. these messages are sent by [send], what means that we could send them through socket from another program (we’ll do this in next step). you can notice that the messages are almost the same to the lines you see when you open a pd patch with a text editor (if you never did this, try it!).
to see how it works, just open sample1.pd. the second file, sample2.pd, is a little bit more complex, with more objects. if you need to create others, i advice you to read damien’s tutorial or yet put the desirable object on a pd file, save and open it in a text editor (remember: the messages are almost the same).
3. the mix!
now, it’s time to make the two steps above together! the stuff works almost like i already described, but now instead using [send] object, we’ll use pdsend file (available in pure data directory) to connect to pd, or yet a simple tcp client. despites, we will initialize a simple server (it contains just a receive object) in -nogui mode. this is the patch we are going to modify dynamicly, so it’s our entrance to pd program.
to show that the stuff really works, i wrote a simple program in python that allows you to create and connect pd objects. to put it to work, just open it and change the given place to where are pdsend and server.pd (variables pdsendDir and serverDir) files.
that’s all! i hope this could be usefull!
 about puredata