[PD] some macro ideas

Chris McCormick chris at mccormick.cx
Tue Oct 3 16:58:19 CEST 2006


On Wed, Oct 04, 2006 at 04:03:38AM +0100, padawan12 wrote:
> On Tue, 3 Oct 2006 14:55:55 +0200
> Frank Barknecht <fbar at footils.org> wrote:
> > I would agree that embedding abstractions can be useful, but where is
> > making a subpatch out of an abstraction useful, 
> 
> > make "wrapper abstractions": I don't change the abstraction itself,
> > but put it inside another abstraction which adds some functionality:
> 
> You know, on reflection this whole debate is best described as "encapsulation"

To me it actually sounds like what you guys want is the Pd equivalent
of inheritance and the overriding of methods. You want an abstraction
which has some basic behaviour, but you also want the ability to keep
that same abstraction and 'override' certain behaviours. Unfortunately
there probably isn't a way to do that in a patching environment where
the program is a 2d netlist. Seems like a similar problem to that of
version control (merging, etc.) of patches.

Actually I'm going to contradict myself straight away. One way to do this
is to pass in the names of your 'method' patches as arguments to some
master patch. So you treat one patch as a "class" and it's arguments as
the names of patches which are it's "methods". Let me give an example:

You have a "class" patch called envelope~ which takes one argument. When
you send an integer to the inlet of envelope~ it makes a line~ of that
length, and passes it through an abstraction called [$1] and sends it to
the output. So you use it like this:

[2000(
|
[envelope~ mylog]
|
[some other stuff~]

"mylog" is the name of a subpatch which itself takes a signal that
goes from 0 to 1 and outputs a nice log envelope. You also have another
subpatch called "pants" which takes a signal that goes from 0 to 1 and
outputs a signal shaped like some pants. Hence you can also call
envelope~ like this:

[2000(
|
[envelope~ pants]
|
[some other stuff~]

In the first case it will create a 2000 millisecond long signal in the
shape of a log envelope. The second will create a 2000 millisecond long
signal in the shape of some pants. Both use the same [envelope~] patch,
which you can keep the same and just change the patches you pass into
it.

Best,

Chris.

-------------------
chris at mccormick.cx
http://mccormick.cx




More information about the Pd-list mailing list