FLOSS Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

PURE DATA Português

PureData: Abstractions

Abstractions

Subpatches are useful to clear code from the main canvas. However, sometimes precisely the same code is used again and again, in which case it isn't convenient to create copies of subpatches. In these cases it is much more useful to call an external patch directly. This kind of patch is known as an abstraction.

Consider a situation where a random note on minor C scale converted to frequency is needed multiple times in one patch. A basic construct for this would be:

cminor0


Every time [random] is banged, one of the displayed numbers will be transposed + 50 and through [mtof] converted to frequency. It's a construct that's inconvenient to reproduce many times in a patch. The abstraction is a separate patch with inlet's and outlets and saved separately.  

 cminor

Saving Abstractions

The abstraction needs to be saved on a path (folder) that Pd looks into each time an object is created. That path (folder) can be defined in Pd preferences however its simpler to have the abstraction in the same folder where the patch that calls it is saved.

Calling and Editing Abstractions

Consider a main patch "cminor-oscilations.pd" saved in /home/user/puredata/ and "cminor.pd" in the same folder. The abstraction (or an instance of it) is called simply by typing the name of the patch (without extension .pd) into an object box.

By clicking on the [cminor] (or right-clicking and choosing "open") the abstraction is opened in new window, just like a subpatch. However now a separate patch (cminor.pd) is being edited. This means when changes are saved all instances in the calling patch are updated.  

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.