Skip to content

py4pd allows write PureData objects using Python. The main goal is to allow easy AI, Scores, Graphics, and bring to Pd data types as array, np.arrays, list, dict, and others.

License

Notifications You must be signed in to change notification settings

charlesneimog/py4pd

Repository files navigation

Logo

py4pd

Python in the PureData environment.

License Release DOI

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/py4pd folder 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 = pd.new_clock(self, self.tick)
        self.args = args

    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")

Building from Source

  • To build from the source code:
cmake . -B build -DPYVERSION=3.12
cmake --build build

On windows you need Mingw64.

About

py4pd allows write PureData objects using Python. The main goal is to allow easy AI, Scores, Graphics, and bring to Pd data types as array, np.arrays, list, dict, and others.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •