Patching

PdPy

class pdpy_lib.patching.pdpy.PdPy(name=None, encoding='utf-8', root=False, pd_lines=None, json=None, xml=None, pdpath=None)[source]

Bases: CanvasBase, Base

addCanvas(pd_lines=None, json=None)[source]

Add a canvas.Canvas object from pure data syntax tokens

addComment(argv)[source]

Add a Comment object from pure data syntax tokens

addCoords(coords)[source]

Adds the Coords class to the canvas

addDependencies(**kwargs)[source]

Handle dependencies called with declare

addEdge(pd_lines)[source]

Add a connection (Edge) object from pure data syntax tokens

addGOPArray(argv)[source]

Add a Graph-on-Parent Array object from pure data syntax tokens

addGraph(argv)[source]

Add the ye-olde array ancestor from pure data syntax tokens

addMsg(argv)[source]

Add a Message object from pure data syntax tokens

addNativeGui(className, argv)[source]

Add a Gui object from pure data syntax tokens

addObj(argv)[source]

Add a Pd object from pure data syntax tokens

addRoot(pd_lines=None, json=None, name=None)[source]

Add a root canvas object from pure data, json, or an empty canvas

Called by the parse() method as well as the pdpy_lib.parse.pdpyparser.PdPyParser class

Return type

The root canvas object

addScalar(pd_lines)[source]

Add a Scalar object from pure data syntax tokens

addStruct(pd_lines=None, json=None, xml=None)[source]

Add a Struct object from pure data syntax tokens

arrangement(choice=-1)[source]

Sets the arranger function

Parameters

choice (int) – The choices are numbered starting at 0. If negative or not one of the available choices, it defaults to arrange1b

getTemplate(template_name)[source]

Get the template related to this object’s Struct

parse(argvecs)[source]

Parse a list of Pd argument vectors (1) into this instance’s scope

This method populates the current class with appropriate calls to individual classes refered to by parsing the argument vector argv.

(1) A pure data argument vector is a list containing a tokenized version of the pure data file line (binbuf), starting with ‘#’ and ending with ‘;’. The tokens are split by spaces, ignoring escaped chars. The special char ‘,’ is handled before calling this method.

restore(argv=None)[source]

Restore constructor called from parse()

run()[source]

Run Pd from the Pure Data binary

write(filename=None)[source]

Write out the pd file to disk

Patch

class pdpy_lib.patching.patch.Patch(name=None, inch=2, outch=2, sr=44100, callback=True, **kwargs)[source]

Bases: PdPy

Patch interface to use pdpy and libpd

Parameters
  • name (str or None) – Name for the patch

  • inch (int) – Number of input channels (defaults: 2)

  • outch (int) – Number of output channels (defaults: 2)

  • sr (int) – Sample rate (defaults: 44100)

  • callback (bool) – Run pyaudio in callback, non-blocking mode. This is useful for recording to disc. Set to False if you want live output (defaults: True).

  • **kwargs – Other keyword arguments are passed to the pdpy.PdPy base class

Example

First, we need to do our import:

>>> import pdpy_lib as pdpy

Now, make a patch with a name and set it to root, non-callback.

>>> patch = pdpy.Patch(name='test', root=True, callback=False)

Create some objects: an oscillator

>>> osc = pdpy.Obj('osc~')
>>> osc.addargs(440)
<pdpy.Obj object at 0x106ac7850>

Now, let’s make a multiplier and a dac objects

>>> mul = pdpy.Obj('*~')
>>> mul.addargs(0.1)
<pdpy.Obj object at 0x106729850>
>>> dac = pdpy.Obj('dac~')

Create the objects and connect them

>>> patch.create(osc, mul, dac)
<pdpy.Patch object at 0x106755640>
>>> patch.connect(osc, mul)
>>> patch.connect(mul, [dac, 0, 1])

Write the patch

>>> patch.write()
Initialized Arranger graph placing algorithm.

Start the audio and perform

>>> patch.start_audio()
<pyaudio.Stream object at 0x106ac74f0>
>>> patch.perform()

You should now hear a sinewave at 440 Hz.

perform()[source]

Begin the audio stream loop

performCallback()[source]

Begin the audio stream loop in callback mode

send(recv, symbol, *args)[source]
start_audio()[source]

Start the pyaudio stream

start_gui(path)[source]
stop_gui()[source]

Canvas

class pdpy_lib.patching.canvas.Canvas(json=None, name=None, **kwargs)[source]

Bases: CanvasBase, Base

Represents a Pure Data canvas, aka subpatch

Besides basic properties, the Canvas class takes #X connect, #X coords, and #X restore into its own namespace, as well as the pure data nodes that are created within the context of a subpatch/canvas window.

Parameters
  • (self.__class__.__name__) (__pdpy__ (str) PdPy className) –

  • ('(subpatch)') (- name (str) The canvas name on parent) –

  • (False) (- gop (bool) Flag to tell if canvas should Graph on Parent) –

  • (False)

  • (None) (- id (int) Identifier number for connections) –

  • (None)

  • (None)

  • (None)

  • (None)

  • (-1) (- __obj_idx__ (int) Number of objects currently on this canvas) –

  • come (The basic properties) –

  • representation (from the pure data file) –

  • Attributes

  • -----------

  • (0 (screen (Point) x-y pair of the top-left window corner on the screen) –

  • 22)

  • (450 (dimension (Size) window width and height dimensions) –

  • 300)

  • (12) (font (int) window font size) –

  • (self.__class__.__name__)

get(id)[source]
get_char_dim()[source]
update_cursor(w_step=0, h_step=0)[source]

Fill objects from top to bottom until we reach bottom (used to be get_position)

Dependencies Class Definition

class pdpy_lib.patching.dependencies.Dependencies(pd_lines=None, json=None, xml=None)[source]

Bases: Base

update(deps)[source]
updateLib(lib)[source]
updatePath(path)[source]

Class Definitions

class pdpy_lib.patching.comm.Comm(send=None, receive=None, json=None, xml=None, default=None, **kwargs)[source]

Bases: Base

Communication Class holding send and receive pairs