[PD] Good programming practice

Frank Barknecht fbar at footils.org
Sat Oct 23 12:42:23 CEST 2004


Hallo,
Peter Todd hat gesagt: // Peter Todd wrote:

> Personally, I use $1 for a kind of address space for abstractions, rather 
> than making things private.  For example, a patch with two similar synths , 
> which uses two similar envelopes, would be structured so that each synth 
> and envelope was given a friendly name (maybe 'lead' or 'bass' or whatever) 
> as the first argument.  Synth-wide parameters use $1.parameterName, while 
> the envelopes have names $1.ampEnv and $1.filterEnv.  Similarly, within the 
> envelope abstraction, $1.parameterName is used for sends and recieves.  So, 
> the sends and recieves for the attack [$1.A] of the lead synth's filter 
> envelope become [lead.filterEnv.A], and so on.  If access to the parameters 
> is desired from anywhere else, there are no particular dirty tricks 
> involved, and nothing changes when you reopen the patch.  Of course, you 
> can still use $0 as part of the name if you want to make it private at a 
> high level.  There isn't too much risk of accidentally conflicting send, 
> receive, values or whatever, but names could get a bit long - so I try to 
> keep them short.

This is not too different from the way, rradical does it, except this:
rradical does keep all things local, while still allowing access
through $1-named addresses. I intentionally did not use send/receive
pairs for this. Although clashes are unlikely with consistently named
sends, they still are possible and require a user to take care of
this. Also sends require a user to remember all these names and write
a lot of [s something] objects. This is fine, if you're the only user,
but as soon as others try to use an abstraction library, things get
too complicated IMO.

Instead all this is solved in rradical through the OSC x-let, which
actually currently doesn't need to use OSC, plain [route] would work
as well, but OSC made it much easier and has several other advantages
(foremost that's pattern matching)

In rradical, no send names have to be remembered at all, because there
are none! This is important. Everything is done through the OSC
inlets, which basically are connected to [OSCroute $1]. This could be
[route $1] as well. Then every parameter, that should be controlled,
has another [OSCroute /paramname] which could be [route paramname] as
well, if you want to avoid OSC.

Now if every OSC inlet is fed by [r OSC] receivers, a user of rradical
has remote control of all parameters through one single global sender,
if (s)he likes to do so, just by sending correctly formatted messages
to it: "; OSC /synth/paramname 20" (OSC) or "; OSC synth paramname 20"
(route, not implemented in rradical). No global sends at all, except
one not named by me, but by the user.

I called this the "strict borders, single crossing" principle in
RRADical.

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__




More information about the Pd-list mailing list