[PD] passing variables to an abstraction
Frank Barknecht
fbar at footils.org
Wed May 12 18:01:25 CEST 2004
Hallo,
Al Riley hat gesagt: // Al Riley wrote:
> I am programming a twenty osciallator additive synth
> with each partial being represented as a version of an
> identical abstraction. I can pass fixed numbers to
> each instance of the abstraction (e.g. I type "partial
> 5 6.33", and retrieve the numbers with "float $1"
> etc) in the object call.
>
> The problem is that the partial weightings are varied
> by the user in real-time so I need to pass this
> variable instead of a fixed number. There are twenty
> weighting values and the correct one has to be passed
> to the relevant instance of the abstraction. I
> initially tried a send object with the corresponding
> receive for each partial embedded in the relevant
> abstraction. I soon realised that changes to the
> abstraction wouldn't be saved so this method wouldn't
> work.
>
> Do I have to create twenty separate abstractions or is
> there a way round this?
>
> Hope this makes sense, Al.
I'm not sure if I do exactly understand your problem, but you can not
only pass floats, but also everything else, especially a symbol. You
can use this symbol as a send/receive name:
[abstraction sendname]
and inside [abstraction] you'd use a [receive $1] to recieve what's
coming in over "sendname".
Another cool trick is what I call $0-passing: If you need to know the
$0 of a parent patch, you can just pass it as an argument as well. So
use:
[abstraction $0]
and inside use: [r $1-receiver] In that case, the $1 inside is the
same number as the $0 in the parent and you have a receiver that is
defined by the parent and still local to that.
I use this a lot in the rradical patches.
Regarding the saving of state, this is a common problem with several
approaches. Obviously I prefer mine, which is in the pd-CVS as
Memento, also described in a PDF-document there.
You can read it here (one line):
http://cvs.sourceforge.net/viewcvs.py/pure-data/abstractions/rradical/doc/rradicalpd.pdf?rev=1.1.1.1&view=auto
Ciao
--
Frank Barknecht _ ______footils.org__
More information about the Pd-list
mailing list