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
- 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 thepdpy_lib.parse.pdpyparser.PdPyParser
class- Return type
The root canvas object
- 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 toarrange1b
- 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.
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
orNone
) – Name for the patchinch (
int
) – Number of input channels (defaults: 2)outch (
int
) – Number of output channels (defaults: 2)sr (
int
) – Sample rate (defaults: 44100)callback (
bool
) – Runpyaudio
in callback, non-blocking mode. This is useful for recording to disc. Set toFalse
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.
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__) –
Dependencies Class Definition
- class pdpy_lib.patching.dependencies.Dependencies(pd_lines=None, json=None, xml=None)[source]¶
Bases:
Base
Class Definitions