py4pd
py4pd allows write PureData Objects using Python instead of C/C++. The main goal is to allow easy IA, Scores, Graphics, and bring to Pd possibilities with array, list and others types. With Python, you can:
* Parse svg/draws as scores;
* OpenMusic functions in libraries like om_py, music21, neoscore, and others;
* Sound analisys with magenta, librosa, and pyAudioAnalaysis;
Wiki | How to install and Use
- Go to Docs (outdated for now), check
Sources/py4pdfolder for examples.
New Pd Object using Python
import puredata as pd
import os
class pymetro(pd.NewObject):
name: str = "pymetro"
def __init__(self, args):
self.inlets = 2
self.outlets = 1
self.toggle = False
if len(args) > 0:
self.time = float(args[0])
else:
self.time = 1000
self.metro = self.new_clock(self.tick)
self.args = args
pd.post("here", os.environ["PY4PD_PATH"])
def in_2_float(self, f: float):
self.time = f
def in_1_float(self, f: float):
if f:
self.toggle = True
self.tick()
else:
self.metro.unset()
self.toggle = False
def in_1_reload(self, args: list):
self.reload()
def tick(self):
if self.toggle:
self.metro.delay(self.time)
self.out(0, pd.SYMBOL, "test238")