Routing different signals to clone instances
@whale-av Thank you very much for your reply! In my case I need to route signal outputs of each cloned object inside one module to another cloned objects inside another module. What I mean is that the first module receives signals from outside of it. I don’t need to route signals between instances of cloned objects inside the module, what i need is to direct multiple signals coming from different instances of cloned objects inside one module and send them outside and then send them to cloned instances inside another module. Hope I managed to explain well enough. Thanks a lot!
Routing different signals to clone instances
@djaleksei You can route separately to specific modules within [clone] by including the clone number in the [send~] and [receive~]
You do that using $ in the name.
Clone 1 will assign the value of 1 to $1...... clone 2 the value 2...... etc,
So if you use [receive~ $1-modulation] then each cloned module can receive separately.
If each osc module is to be paired with each modulation module thenit is a simple task...... putting [send~ $1-modulation] in the modulation cloned abstraction will have fmmod1 send to osc1, fmmod2 send to osc2 etc.
You can give [clone] more arguments..... giving you the possibility to use $2, $3 etc. for more complexity...... i.e. if you one day add another bank of cloned oscillators to your patch.......
https://forum.pdpatchrepo.info/topic/9774/pure-data-noob/4
David.
Routing different signals to clone instances
Hello all!
I’m new to this forum! However I’ve been working with Pd for a while. Currently I’m programming a polyphonic synth in Pd with FM capabilities and I’m facing a problem. I have created some sort of a module which includes one oscillator, a low pass filter and an ADSR envelope generator. The output of this module is an audio signal. It also includes some inputs and one of them is a signal input for frequency modulation (it receives a signal from the outside and uses it to modulate the frequency of the oscillator inside the module). I use clone command to create multiple instances of the same module to make it polyphonic. Then I tried to route a signal from another cloned module to the FM input of the first module and the obvious ocurred: when I play only one note the FM works as supposed to. But when I play multiple notes it sounds terrible and it is because the audio signal of all the notes from the second module goes to the FM input of the first module and then it is routed to all the cloned instances of it. What I need is to route only the signal corresponding to one note and route it to the same note of the first module. Is there any way to achieve this? I understand that a signal goes equally to all instances of a cloned object, but is it possible get separate signals from all instances of the second module and route them separately to the corresponding instances for the first module?
hcube: hypercube calculator using 4 layers of nested clones and a dynamic [expr]
hcube: hypercube calculator using 4 layers of nested clones and a dynamic [expr]
Preface:
Mainly I did this for two reasons, 1) to see what it would look like to have a 4-d "tree" of clone objects and 2) I think it's funny (in a pure data sense).
As to practical purposes...I leave that up to the user.
Though, being (sort of) 4-d, I think it lends itself to audio sequencers, samplers, and esp. GEM projects.

requires: iemguts
(See hcube-help.pd for more detailed info.)
hcube is a series of four nested clones: cube, table, row, col(umn), with col holding a dynamically generated [expr] object.
It is created using arguments for the number of cubes, tables/cube, rows/table, and columns/table plus an expr, in [expr] notation where $f1 is the variable, $f2 is cube index, $f3 table, etc.
It reports the calculated result, i.e. sends [send]s, in the format [r #-#-#-#] where the numbers represent the (1-indexed) index of the object, ex. [r 1-1-1-1] is the first cube, first table, first row, and first column result.
It can take messages in the format [cubeidx tableidx rowidx columnidx variable formula]. Where if idx=0 then the messages is sent to [all ( clones and if >0 the message is sent to that (index=N-1) item.
The abstraction lends itself to changing the variable, locations, and (esp.) [expr] formulas on the fly, i.e. over time. So sending the variable down the chain and getting a cascade of values. (There is an example of this in the help file.)
I hope it may give you either 1) some use or 2) a giggle.
Now more than ever: Peace and Love through sharing.
Stay safe.
-S
p.s. it's my guess iemmatrix may already do this, but from a logic standpoint, using the clones like this, I think makes a lot of sense and is easy to follow.
Which [this( is this?
I'm new to the [clone] game. Is there a way to poll the [clone] object to see which instance number it's currently on?
Let's say I've got 16 cloned synths. I'm semi-randomly changing certain parameters, of one synth at a time, but it doesn't really matter which one. I've been doing this with [next( and [this(. But I'm curious to see WHICH instance I've changed, say, "rate" on, and which one had "onset" increased.
Does this make sense? Well, my particular use-case isn't that relevant; I'm just wondering about asking [clone] which synth-instance its counter, as triggered by [next(, is on.
Do clones dream of their siblings?
I've written patches with clones where each clone needed to know:
[1] how many siblings it had
[2] data from its preceding and following clone
[3] whether the preceding or following clone exists
To do [1], I've had each clone send its instance number ($1) to a known global destination. Since it appears that clones are created in ascending order, this works as long as you adjust for the start index (again, something that clones don't automatically just know). I haven't found anything that says this creation order is specified, nor have I found a way to set the number of clones from some external value, so I regard my solution to be a hack. Can I count on this order, or should I use [max] on every incoming instance number?
For [2], I've used [value] with identifiers that include each clone's instance number. It's a small PITA when accessing other sibling's values because you can't do arithmetic on the instance number in the preprocessor; you have to make it explicit, e.g.

The last is similar to [2], except that I just initialize a "clone$1exists" value to 1. It appears that if you ask PD for a value that doesn't exist, it returns 0.
Are there better ways to do these things that don't require manual housekeeping or rely on undocumented features?
Using PD more efficiently?
Speaking of efficiency: There's ChucK code that does spectral analysis and outputs a list of peak frequencies and their amplitudes in this format:
[ 4072.47, 1 ], [ 5593.25, 0.304494 ], [ 4196.28, 0.66348 ], [ 5536.73, 0.726691 ], [ 4382.01, 0.527432 ], [ 5380.61, 0.722193 ], [ 4766.91, 0.287018 ], [ 7073.66, 0.620362 ], [ 5334.85, 0.513121 ], [ 5490.97, 0.267715 ], [ 5046.84, 0.342458 ], [ 7006.37, 0.657309 ], [ 6629.53, 0.451136 ], [ 6939.07, 0.525416 ], [ 9520.37, 0.254127 ], [ 9388.48, 0.253434 ], [ 7396.66, 0.225276 ], [ 9582.28, 0.259454 ], [ 8990.11, 0.168725 ], [ 9703.4, 0.247069 ]
which you can easily click and paste into another ChucK script that will resynthesis a sound with that spectrum.
If I wanted to use this data in another text-based language, I could make or adapt a parsing script that removes the brackets and sends the left value into a frequency array and the right value into an amplitude array. But in PD, even if I use abstractions or [clone], I would still have to either manually go in and cut the individual values and paste them into a message box or into an abstraction as a creation argument. I suppose if I could convert them into two lists, one for frequency and one for amplitude, eg. I could send them into a [clone] easily, eg.
[4072.47, 5593.25, 4196.28, etc.(
|
[next $1(
|
[clone]
I've made a parsing script before to read parameter list txt-files into C#, so I'd have to look into how to generate .txt files. So the process would be
- Get ChucK analysis data.
- Paste it into algorithm to generate two txt-files in the proper format.
- Copy and paste content of those files into PD message boxes.
This would work for testing in PD, but since hvcc isn't compatible with [clone], I'd have to wire up a route system into regular abstractions.
Any better ideas for how to do this? Is there a way to do the parsing in PD itself?
(I know @Jona mentioned ofelia. So the question is what's more work and what has more payoff. Doing it the way I described or learning ofelia?)
How to send a message to all clones whitout s/r
If you are trying to make some polyphony using clone object and you need to find a free voice you can use : [your midi pitch]-[next $1] - [clone synth.cl nr_of_voices]. [next $1] is a message object that will find a free voice for your clone object. "nr_of_voices" is your number of voices for the clone object. "synth.cl" is your abstraction for one voice.
Help with [key]/[keyup] inside [clone]
@4ZZ4 I forgot to remove [notein] and it can be deleted.
[pd debounce] is purely to remove repeated notes sent by the OS.... while not removing intentional repeated notes.
Yes... [$1 $1( duplicates the key number and so sends it to the correct cloned abstraction [bonkers] so each key only goes to the [bonkers] that has its number...... the first $1 is stripped by clone as it is routed (see below).
[route float reset] sends a float out its left outlet (removes the float header but sends on the actual float value) and routes the reset message to bang [-1(
[change] will not let repeated numbers through...... but when it has value -1 "set" it will see that -1 as the last number and let through any other value that arrives..... your key numbers...... which are all positive. So it will not let 34 34 through. But 34 reset 34 it will let through. The reset message comes from the [keyup] so until the key is up it will not let the same key through again.
A keyboard that continually sends 34 34 34 34 34 when the key is held down will only send 34 all the way through.
My keyboard with 34 and 35 and 36 held down would send 34 35 36 35 36 35 36 35 36........ which one [change object would not block..... so [bonkers] is a separate [change] for every key with a reset when the key is actually lifted.
At the same time the keyup is sent through to the voices to stop the note..... and it only arrives once as the key is lifted.
With clones the first float in a list determines which clone the message goes to.
So with [pack f f f] the first f says which clone...... and that is stripped by clone and only the second and third f's arrive in that clone....... so [unpack f f]
Message [34 5 8( from [pack f f f] arrives in clone 34 as [5 8(
Just before [s oct]....... you tell me why there is a [t b f] before [+]....... I just copied that bit from your patch........
He he.
You are right...... the [t b f] can go in the bin.
Does it all work how you want now? I have been out all day and will be again this evening.
David.
David.
Help with [key]/[keyup] inside [clone]
@4ZZ4 Yes. Key objects require an open focused window because they grab keys that are only sent by the operating system to the current focused window.
You will have to use it outside clone unfortunately and send the command into clone directly or with a send / receive.
You can add extra arguments to clone if you need to so that the cloned objects in only one [clone] receive those messages sent by a [send]....... all cloned objects in one [clone] that is....... if you have a second [clone] with the same objects....
David.




