Search code examples
cpuredata

Communicating with Pure Data in C


I'm looking for a way to be able to communicate with a Pure Data patch via C programming - I suppose this is different from writing an external in C which involves writing patches themselves. I only need to communicate and make changes in existing patches. For instance, in the patch shown in the image: enter image description here

I need to find a way to change the delay parameters programmatically, in the case of the three objects delwrite~, *~, and delread~. I wish to write a simple C program that communicates with Pure Data, loads the patch and makes the required changes. Any insights would be appreciated.


Solution

  • there are numerous ways to communicate with a running Pd instance.

    The most straightforward one is to use network communication:

    • [netreceive] allows you to receive messages from another process, using the FUDI protocol. The following patch listens on UDP/9999 for incoming messages:

    network controlled feedback patch

    • on the C-side, just create a normal UDP-socket and send the data to localhost:9999 (assuming your process runs on the same machine).

    Alternative methods include using libpd, which is a library version of Pd and allows you to load Pd-patches directly in your program.