Is there a way for a clone instance to determine the total number of clones?
Because often the behavior of a clone depends on its relative position within a chain of instances.
"I am instance 12 of 100, therefore, I should behave like so...."
I find myself passing in the number of total clones as a parameter. I would like to avoid this if possible.
Thanks, BH
-- William Huston: WilliamAHuston@gmail.com Binghamton NY
*Public Service Mapping / Videography / Research / Education / Safety Advocacy* Blog http://WilliamAHuston.blogspot.com -- Facebook http://facebook.com/billhuston -- Twitter http://twitter.com/WilliamAHuston-- Youtube https://www.youtube.com/channel/UCGijK1amWOLglT3YeTyEBNQ?sub_congfirmation=1
*Document collections*: VirtualPipelines http://TinyURL.com/VirtualPipelines -- BHDCSDimockArchive http://bit.ly/BHDCSDimockArchive *Please support my work! -- *TinyURL.com/DonateToBillHuston
I find myself passing in the number of total clones as a parameter.
Yes, that's the only way.
I would like to avoid this if possible.
Why? Is it only for cosmetic reasons, or for technical reasons?
Yes, [clone foo 20 20] might look ugly, but it does the job. Personally, I haven't ever needed the number of cloned instances inside an instance... but if you need it frequently, you can make a feature request on GitHub.
Christof
On 03.03.2021 20:12, William Huston wrote:
Is there a way for a clone instance to determine the total number of clones?
Because often the behavior of a clone depends on its relative position within a chain of instances.
"I am instance 12 of 100, therefore, I should behave like so...."
I find myself passing in the number of total clones as a parameter. I would like to avoid this if possible.
Thanks, BH
-- William Huston: WilliamAHuston@gmail.com mailto:WilliamAHuston@gmail.com Binghamton NY
*Public Service Mapping / Videography / Research / Education / Safety Advocacy* Blog http://WilliamAHuston.blogspot.com -- Facebook http://facebook.com/billhuston -- Twitter http://twitter.com/WilliamAHuston-- Youtube https://www.youtube.com/channel/UCGijK1amWOLglT3YeTyEBNQ?sub_congfirmation=1*-- Podcast Blog https://billhustonpodcast.blogspot.com/
*Document collections*: VirtualPipelines http://TinyURL.com/VirtualPipelines -- BHDCSDimockArchive http://bit.ly/BHDCSDimockArchive *Please support my work! -- *TinyURL.com/DonateToBillHuston http://TinyURL.com/DonateToBillHuston
**
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
i sometimes used the attached idiom, which works in certain circumstances. (using the [max] object). christofs solultion is more sane though…
hans
Am 03.03.2021 um 21:34 schrieb Christof Ressi info@christofressi.com:
I find myself passing in the number of total clones as a parameter.
Yes, that's the only way.
I would like to avoid this if possible.
Why? Is it only for cosmetic reasons, or for technical reasons?
Yes, [clone foo 20 20] might look ugly, but it does the job. Personally, I haven't ever needed the number of cloned instances inside an instance... but if you need it frequently, you can make a feature request on GitHub.
Christof
On 03.03.2021 20:12, William Huston wrote:
Is there a way for a clone instance to determine the total number of clones?
Because often the behavior of a clone depends on its relative position within a chain of instances.
"I am instance 12 of 100, therefore, I should behave like so...."
I find myself passing in the number of total clones as a parameter. I would like to avoid this if possible.
Thanks, BH
-- William Huston: WilliamAHuston@gmail.com Binghamton NY
Public Service Mapping / Videography / Research / Education / Safety Advocacy Blog -- Facebook -- Twitter -- Youtube -- Podcast Blog Document collections: VirtualPipelines -- BHDCSDimockArchive Please support my work! -- TinyURL.com/DonateToBillHuston
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
On 3/3/21 9:51 PM, hans w. koch wrote:
i sometimes used the attached idiom, which works in certain circumstances. (using the [max] object).
for such counting i typically use [value]. as in:
[loadbang] | [t b b] | [value foo] | [+1] | [value foo] | [delay 0] [value foo] |
with "foo" being replaced by some unique symbol shared among all instances.
this is of course more useful outside of [clone] (where christof's suggestions is much nicer), e.g. when dealing with multiple GOP-abstractions.
masfd IOhannes
On 3/3/21 9:34 PM, Christof Ressi wrote:
Yes, [clone foo 20 20] might look ugly,
well. otoh it looks quite elegant inside the cloned abstraction: $1 - id of current instance $2 - number of instances $3... - other args
i can't think of an interface to get the total number of instances inside the abstraction that is not much, much uglier.
somethiung like
[clones( | [pdcontrol] |
:facepalm:
gfmards IOhannes
I can imagine adding a flag to [clone] to automatically pass the number of instances as the second argument:
[clone -n foo 20] == [clone foo 20 20]
but I'm not sure it's worth it...
On 03.03.2021 22:11, IOhannes m zmölnig wrote:
On 3/3/21 9:34 PM, Christof Ressi wrote:
Yes, [clone foo 20 20] might look ugly,
well. otoh it looks quite elegant inside the cloned abstraction: $1 - id of current instance $2 - number of instances $3... - other args
i can't think of an interface to get the total number of instances inside the abstraction that is not much, much uglier.
somethiung like
[clones( | [pdcontrol] |
:facepalm:
gfmards IOhannes
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
just saying I usually have to send the total number of clones as an argument.
Em qua., 3 de mar. de 2021 às 19:53, Christof Ressi info@christofressi.com escreveu:
I can imagine adding a flag to [clone] to automatically pass the number of instances as the second argument:
[clone -n foo 20] == [clone foo 20 20]
but I'm not sure it's worth it...
nah, it's ugly, you need to do something weird instead of just sending the argument. It'd be good if this was retrievable as an argument in the first design, now we have to live with it or break compatibility
; pd compatibility-flag 0.51 < ______________________
:facepalm:
On Wed, Mar 3, 2021, 3:37 PM Christof Ressi info@christofressi.com wrote:
I find myself passing in the number of total clones as a parameter.
Yes, that's the only way.
Thanks Christof.
I would like to avoid this if possible.
Why? Is it only for cosmetic reasons, or for technical reasons?
Yes, mostly aesthetics. It seems redundant. It creates extra work. It would simply my development workflow.
I'm communicating to my clones via arrays. Each clone reads values from certain arrays, and writes values to other arrays.
(In the output case, the clone instance number always corresponds to the array element number, so I can see what each clone is doing. On the input case, I'm reading at audio rate
So when I change the number of clones, I must change this in the 2 places you've mentioned. I also have to resize my arrays, which requires changing at least 1 message. (I imagine that I can probably change all my arrays using a single compound message, but haven't tried this yet).
Ideally, it would be nice to change N in *one place*. I think this might be possible if the first feature was implemented.
e.g., "If I am instance #1, and the number of instances has changed since last time (stored in a global variable), then resize my arrays".
Yes, [clone foo 20 20] might look ugly, but it does the job. Personally, I
haven't ever needed the number of cloned instances inside an instance...
I am still working on converting my 12 band flanger/auto panner to an N-band Flanger using clone.
If we think about the clones spreading out and creating an equal phase displacement across all N bands, and if we let S be the instance number, then we can calculate the phase displacement for an arbitrary instance like this:
PhaseDisplacement(S) = (2π / N) * S So each clone needs to know the value of both S ($1) and N.
but if you need it frequently, you can make a feature request on GitHub.
I think I will, thanks!
BH
Christof
On 03.03.2021 20:12, William Huston wrote:
Is there a way for a clone instance to determine the total number of clones?
Because often the behavior of a clone depends on its relative position within a chain of instances.
"I am instance 12 of 100, therefore, I should behave like so...."
I find myself passing in the number of total clones as a parameter. I would like to avoid this if possible.
Thanks, BH
-- William Huston: WilliamAHuston@gmail.com Binghamton NY
*Public Service Mapping / Videography / Research / Education / Safety Advocacy* Blog http://WilliamAHuston.blogspot.com -- Facebook http://facebook.com/billhuston -- Twitter http://twitter.com/WilliamAHuston-- Youtube https://www.youtube.com/channel/UCGijK1amWOLglT3YeTyEBNQ?sub_congfirmation=1
- -- Podcast Blog https://billhustonpodcast.blogspot.com/ *
*Document collections*: VirtualPipelines http://TinyURL.com/VirtualPipelines -- BHDCSDimockArchive http://bit.ly/BHDCSDimockArchive *Please support my work! -- *TinyURL.com/DonateToBillHuston
_______________________________________________Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
On 3/4/21 12:23 AM, William Huston wrote:
Ideally, it would be nice to change N in*one place*. I think this might be possible if the first feature was implemented.
hoiw about your own little abstraction wrapper?
[inlet~]
|
[clone foo $1 $1 $0-]
|
[outlet]
[array define $0-control $1]
[array define $0-data]
[loadbang]
|
[float $1]
|
[* 10]
|
[resize $1(
|
[s $0-data]
so you only need to change [clonefoo 10] to [clonefoo 39] and it will create 39 clones for you, each of them knowing the total number of clones. it will also make sure that the "control" array has the same size as there are clones, and that the "data" array has 10* that size. as you can see, "resizing" the "control" array is trivial; resizing to a size different from the number of elements requries a bit of code.
"If I am instance #1, and the number of instances has changed since last time (stored in a global variable), then resize my arrays".
that's probably a misunderstanding here, how [clone] works.
10 instances of [foo] and create 20 *new* instances. the new instance #1 has no relationship with the old instance #1 (apart from being read from the same abstraction and sharing the same arguments). esp. it has no knowledge about anything that might have happened before the [clone] object was changed. so there is no "since last time".
mdgfasr IOhannes