[PD] First patch for performance

Frank Barknecht fbar at footils.org
Sun Feb 13 17:38:42 CET 2005


Hallo,
amatheso at alcor.concordia.ca hat gesagt: // amatheso at alcor.concordia.ca wrote:

> thanks for the input. Making the loopers into thier own seperate abstraction 
> is a great idea. I'm a little confused on making an arguement for the array 
> though. basically i just name the array $1-sample and use the same name in 
> the tabread4~ and the soundfiler message? 

Yes, exactly. And then you create the loopers like: [looper 123].

> this won't conflict if use it more than once in a patch?

No, it won't, if you specify different arguments in every use of your
abstraction like: 
  
  [looper 1] 
  [looper 2] 
  [looper three]

Another possibility would be to use the special variable "$0" instead.
$0 gets replaced by a unique number for each instance of an
abstraction.

Example: 

Inside looper.pd you have this: 

  [table $0-tab]
  ...
  [tabread4~ $0-tab]
  ...
  [print $0-tab]

Then in the parent patch you create two [looper] objects without any
arguments:

  [looper]
  ...
  [looper]


In both looper abstractions Pd will now replace $0 internally with a
(more or less random) unique number, lets say in the first one it will
be 1000 and in the second one it's 1010

You then in fact have a structure like this: 


  [table 1000-tab]
  ...
  [tabread4~ 1000-tab]
  ...
  [print 1000-tab]



  [table 1010-tab]
  ...
  [tabread4~ 1010-tab]
  ...
  [print 1010-tab]

If you "bang" the print-objects, you can see the number that was
chosen by Pd. 

The net effect is, that the [tabread4~ $0-tab] always will only read
the table in its own patch/abstraction and not the other one.

"$0-tab" also is called a "local variable" in this case, as it is
"private" to the abstraction and not globally accessible from the
outside (unless you use some special tricks). You can also use it in
sends and receives: [s $0-x] ... [r $0-x] if you want to send only
locally inside an abstraction.

My patches practically only use $0-sends. Adding $0 has become such a
habit, I really have to concentrate on *not* typing the "$0-"
automatically if I indeed want a global send. ;) I would say, using
$0 a lot is an example of "Pd Best Practices".

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
             _ __latest track: fqdn _ http://footils.org/cms/show/38




More information about the Pd-list mailing list