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:
http://jeraman-lab.googlecode.com/svn/trunk/dynamicPatching/
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!
thanks to: jarbas jacome, for his tips, and damien henry, for his brilliant tutorial about dynamic pathing!
further informations:
[1] about puredata
[2] damein henry’s tutorial about dynamic patching;




March 23, 2009 at 12:03 am
great job, jera!
dynamic patching is just wonderful… I wonder build “live” instruments that modify itself reacting to the musician playing.
hugs!
jjR
May 8, 2009 at 3:12 am
[...] was developed using a technique known as “dynamic patching” (already cited in this blog), which is based on dynamic creation of Pd objects (aka dynamic patching) realized through sockets. [...]
March 21, 2010 at 10:02 pm
[...] iemguts e dynamic patching March 21, 2010 apesar do resultado com o PyPd ter sido interessante para meu propósito na época, no tocante a utilização intensiva a biblioteca não ficou tão estável e completa, quanto desejado inicialmente. com o objetivo de corrigir tais problemas, decidir retomar meus estudos sobre Dynamic Patching. [...]
July 31, 2010 at 2:20 am
[...] project is freely available on GitHub. PureéData is in part adapted from code by Jeraman. var a2a_config = a2a_config || {}; a2a_config.linkname="PureéData: Realtime Collaborative [...]