hi there,
because there is no real documentation on this 'hack' i thought i'd query the pd-list hive-mind first:
regarding the self modifying patches (sending messages to pd-blah.pd etc), is it possible for an abstraction to reference itself somehow? what is the name of the object that you send the messages to?
my real query is, can an abstraction 'reconfigure itself' based on a parameter supplied at creation time?
pix.
wow, i just found myself asking almost the same question earlier this year, on this list *slap*.
okay, so miller writes:
If you name a subpatch "fred" for instance, you can send messages to "pd-fred". I've used it to add text comments to windows automatically, but in principle you should be able to do anything that appears in a
saved
Pd file (adding and connecting objects).
the problem here is that if you have two abstractions called fred, the actions appear to happen to both of them (i've just been playing with the selectall at the moment), which makes it a little less useful than i had first imagined.
is this something that can be avoided?
pix.
On Tue, 25 Sep 2001 11:45:44 +0200 pix pix@test.at wrote:
hi there,
because there is no real documentation on this 'hack' i thought i'd query the pd-list hive-mind first:
regarding the self modifying patches (sending messages to pd-blah.pd etc), is it possible for an abstraction to reference itself somehow? what is the name of the object that you send the messages to?
my real query is, can an abstraction 'reconfigure itself' based on a parameter supplied at creation time?
pix.
another self reply... sorry for making so much noise on the list while i talk to myself. but anyhow, i worked out how to accomplish what i want (which is a little hard to explain right now), but i realised that by manually editing the name of an object in the .pd file to be (for example) "$1", then you can change the name of that object using a parameter to the abstraction (as long as it has the same configuration of in's and out's). with some craftily designed sub-abstractions you can use this to reconfigure the abstraction at creation time.
pix.
On Tue, 25 Sep 2001 11:53:40 +0200 pix pix@test.at wrote:
wow, i just found myself asking almost the same question earlier this year, on this list *slap*.
okay, so miller writes:
If you name a subpatch "fred" for instance, you can send messages to "pd-fred". I've used it to add text comments to windows automatically, but in principle you should be able to do anything that appears in a
saved
Pd file (adding and connecting objects).
the problem here is that if you have two abstractions called fred, the actions appear to happen to both of them (i've just been playing with the selectall at the moment), which makes it a little less useful than i had first imagined.
is this something that can be avoided?
pix.
On Tue, 25 Sep 2001 11:45:44 +0200 pix pix@test.at wrote:
hi there,
because there is no real documentation on this 'hack' i thought i'd query the pd-list hive-mind first:
regarding the self modifying patches (sending messages to pd-blah.pd etc), is it possible for an abstraction to reference itself somehow? what is the name of the object that you send the messages to?
my real query is, can an abstraction 'reconfigure itself' based on a parameter supplied at creation time?
pix.
pix wrote:
hi,
but then, do you really need to wrap those sub-abstractions?
I mean, instead of using [selfmodif blah] and [selfmodif ding] (where selfmodif.pd wrapper contains a [$1] object) maybe it would be easier to use just [blah] and [ding] in the main window?
Btw. putting [$1] object in a window is possible, and it will be saved as "#X obj <x> <y> $1" -- no need to hack the .pd file.
Krzysztof
another self reply... [...] i realised that by manually editing the name of an object in the .pd file to be (for example) "$1", then you can change the name of that object using a parameter to the abstraction (as long as it has the same configuration of in's and out's). with some craftily designed sub-abstractions you can use this to reconfigure the abstraction at creation time.
well if you can imagine an abstraction with a lot of complicated logic wrapping around some object, but that object could possibly be exchanged with other objects to change the behaviour in some interesting way, then this becomes handy.
if you wanted to do this "in the main window" you would have to duplicate all of this logic.
but anyhow, everything you can do in an abstraction can always just be done in the main window, the idea of an abstraction is to make it easier/neater.
like procedural programming.. you don't always make functions/procedures because they are _necessary_, they are also a conceptual aid... they _abstract_ over details which are not immediately necessary.
i think i'm breaking some kind of rule by talking about style so close to talk about self modifying code :)
pix.
On Tue, 25 Sep 2001 13:42:32 +0200 Krzysztof Czaja czaja@chopin.edu.pl wrote:
pix wrote:
hi,
but then, do you really need to wrap those sub-abstractions?
I mean, instead of using [selfmodif blah] and [selfmodif ding] (where selfmodif.pd wrapper contains a [$1] object) maybe it would be easier to use just [blah] and [ding] in the main window?
Btw. putting [$1] object in a window is possible, and it will be saved as "#X obj <x> <y> $1" -- no need to hack the .pd file.
Krzysztof
another self reply... [...] i realised that by manually editing the name of an object in the .pd file to be (for
example)
"$1", then you can change the name of that object using a parameter
to
the abstraction (as long as it has the same configuration of in's and out's). with some craftily designed sub-abstractions you can use this
to
reconfigure the abstraction at creation time.
hi,
ok, passing by name is one way to go, it is a matter of taste.
Of course I did not mean duplicating. Your logic may live in one instance of [logic] connected (locally or globally) to [blah] and another instance of [logic] connected to [ding]. But maybe using [logic blah] and [logic ding] could sometimes suit better (depending on taste).
Krzysztof
pix wrote:
well if you can imagine an abstraction with a lot of complicated logic wrapping around some object, but that object could possibly be exchanged with other objects to change the behaviour in some interesting way, then this becomes handy.
if you wanted to do this "in the main window" you would have to duplicate all of this logic.
oh, btw, you do have to edit the .pd file, because if you just make a [$1] object, it has no inlets or outlets... so you need to make the abstraction using real object first that has the right number (at least, if not type) of in's+out's, then change it's name to "$1" in the file so that the connections are preserved.
pix.
On Tue, 25 Sep 2001 14:21:22 +0200 Krzysztof Czaja czaja@chopin.edu.pl wrote:
hi,
ok, passing by name is one way to go, it is a matter of taste.
Of course I did not mean duplicating. Your logic may live in one instance of [logic] connected (locally or globally) to [blah] and another instance of [logic] connected to [ding]. But maybe using [logic blah] and [logic ding] could sometimes suit better (depending on taste).
Krzysztof
pix wrote:
well if you can imagine an abstraction with a lot of complicated logic wrapping around some object, but that object could possibly be
exchanged
with other objects to change the behaviour in some interesting way,
then
this becomes handy.
if you wanted to do this "in the main window" you would have to
duplicate
all of this logic.
hi,
indeed, but this is an argument for using [logic]->[blah] instead of [logic blah] with [$1] inside.
If you are into hacking, then have a look at my self-modifying subpatches. First put 'selfmodif.pd' abstraction where Pd can find it, then open 'show-selfmodif.pd', and wait 4 seconds.
Krzysztof
pix wrote:
oh, btw, you do have to edit the .pd file, because if you just make a [$1] object, it has no inlets or outlets... so you need to make the abstraction using real object first that has the right number (at least, if not type) of in's+out's, then change it's name to "$1" in the file so that the connections are preserved.
#N canvas 83 71 583 433 12; #X obj 413 20 selfmodif blah; #X obj 54 20 loadbang; #X obj 238 124 delay; #X obj 237 20 selfmodif ding; #X obj 170 355 r pd-blah; #X obj 57 355 r pd-ding; #X obj 57 394 print ding; #X obj 170 394 print blah; #X obj 284 355 r pd-selfmodif.pd; #X obj 284 394 print selfmodif.pd; #X msg 54 52 1; #X obj 54 84 makefilename $%d; #X obj 416 124 delay; #X obj 416 86 r delay-blah; #X msg 416 162 ; pd-blah menuclose; #X msg 238 162 ; pd-ding menuclose; #X obj 238 86 r delay-ding; #X msg 54 228 ; pd-selfmodif.pd vis 1 ; pd-selfmodif.pd obj 200 10 pd $1 ; pd-ding text 50 50 this subpatch can be self-modified ; delay-blah 2000 ; delay-ding 4000; #X connect 1 0 10 0; #X connect 2 0 15 0; #X connect 4 0 7 0; #X connect 5 0 6 0; #X connect 8 0 9 0; #X connect 10 0 11 0; #X connect 11 0 17 0; #X connect 12 0 14 0; #X connect 13 0 12 0; #X connect 16 0 2 0;
#N canvas 0 0 454 398 12; #N canvas 0 0 600 400 Pd 0; #X restore 73 213 pd $1-btw-it-does-not-work; #X text 41 132 put your logic in this abstraction...;
pix wrote:
wow, i just found myself asking almost the same question earlier this year, on this list *slap*.
okay, so miller writes:
If you name a subpatch "fred" for instance, you can send messages to "pd-fred". I've used it to add text comments to windows automatically, but in principle you should be able to do anything that appears in a
saved
Pd file (adding and connecting objects).
the problem here is that if you have two abstractions called fred, the actions appear to happen to both of them (i've just been playing with the selectall at the moment), which makes it a little less useful than i had first imagined.
is this something that can be avoided?
hi !
the most simple thing would be: using "namecanvas $0-fred" somewhere in the abstraction and then talking to (modifying) an object $0-fred, as you are used to to this. i always do it this way, so i can be (quite) sure, that i am modifying only the current patch.
again:: no matter, what pd says, "namecanvas" is not obsolete !!!
(i think, this might is the answer i gave you "earlier this year")
mfg.cs.asdt IOhannes
hey thanks (again, maybe) :)
this is exactly what i was trying to do.. tho the [$1] solution i stumbled across actually turns out to be a lot easier in my specific case.
pix.
On Tue, 25 Sep 2001 13:50:46 +0200 IOhannes m zmoelnig zmoelnig@iem.kug.ac.at wrote:
pix wrote:
wow, i just found myself asking almost the same question earlier this year, on this list *slap*.
okay, so miller writes:
If you name a subpatch "fred" for instance, you can send messages to "pd-fred". I've used it to add text comments to windows
automatically,
but in principle you should be able to do anything that appears in a
saved
Pd file (adding and connecting objects).
the problem here is that if you have two abstractions called fred, the actions appear to happen to both of them (i've just been playing with
the
selectall at the moment), which makes it a little less useful than i
had
first imagined.
is this something that can be avoided?
hi !
the most simple thing would be: using "namecanvas $0-fred" somewhere in the abstraction and then talking to (modifying) an object $0-fred, as you are used to to this. i always do it this way, so i can be (quite) sure, that i am modifying only the current patch.
again:: no matter, what pd says, "namecanvas" is not obsolete !!!
(i think, this might is the answer i gave you "earlier this year")
mfg.cs.asdt IOhannes