I have a mic patch on Pure Data and I want to connect it to a loudspeaker patch. So, it has the command connect localhost 3000
, where localhost indicates where the loudspeaker patch is and 3000 is the port number that I will use for connection. Is it possible to send this message using a python script, so I don't have to click on the patch?
I'm using libpd for this.
Asked
Active
Viewed 300 times
0

Rômulo Vieira
- 3
- 3
-
2that's a duplicate of https://stackoverflow.com/questions/67209375 (unfortunately i cannot mark this question as a duplicate, as the OP of the older one has decided to not upvote/accept the only answer) – umläute Jul 08 '21 at 06:41
-
1alternatively i didn't fully understand your question. how are "python" and "puredata" connected? as you mention libpd: is your python application a libpd host? – umläute Jul 08 '21 at 06:44
-
1are you sure you are *using* libpd? that snippet you posted looks like a profound misunderstanding of how to use it. with libpd, you load a full instance of Pd within your (python) application - this requires more than just `import pylibpd`. once you have Pd running *within* your application, you can send messages to it. you **cannot** use libpd to make python talk to a **separate** Pd instance (e.g. that was started separately) – umläute Jul 08 '21 at 20:21
1 Answers
1
libpd comes with some documentation and a few examples that explain how to use the API. If the Python API docs are not detailed enough, check the documentation for some other language binding - the bindings for the different languages are typically very similar.
Basically, you can simply send a trigger to a receiver within Pd, using libpd_bang
.
Python:
libpd_bang("connect-to-speaker")
Pd:
[receive connect-to-speaker]
|
[connect localhost 3000(
|
you can of course send some payload using libpd_float()
or libpd_list()
or libpd_message()
.
alternatively, you could also have Pd trigger the [connect(
message automatically, using [loadbang]
.

umläute
- 28,885
- 9
- 68
- 122