Changing an array in a Synth

I know that you have to be careful about how you send an array to a Synth - and that the maximum size can’t be changed. But is there a way to dynamically shorten an array inside of a synth?

			var test = Array.fill(20, {1.0.rand});
			test = test[0..count].poll;

No. Any change to an array size also changes the structure of the SynthDef, and changes to the structure of a SynthDef are never supported from SynthDef arguments. There’s no exception to this rule.

What you can do is to use only the ones you need.

			var test = Array.fill(20, {1.0.rand});
			var trigs = * Array.fill(20, { |i| i < count });
			test = test.poll(trigs);



Thanks, @jamshark70 - I can see that this works - but I’m not sure if I totally understand what’s happening here.

We’re creating a second array that has a “1” if the value is less than the “count” and a “0” otherwise. .and I’m assuming the is triggering the polling.

But let’s say I wanted to use only the parts of an array that we’ve selected here, I’m not exactly sure how I would apply it to something like a SinOsc… something along the lines of this, for instance., 0, 0.01)));

Like this?

// k random sine tones across stereo field, MouseX selects which to listen to
    var k = 20;
    var mouseX =, k, 0, 0.2);
    var select = (0 .. k).collect({ arg i; mouseX > i });
    var note = { [0, 2, 3, 5, 7, 9, 10].choose + [48, 60].choose }.dup(k);
    var osc =, 0) * select * 0.05;, 1, 1, 0, true)
1 Like

And, to backfill the theory – at the end of the day, both my code snippet and rdd’s work in the same way: by passing or suppressing a signal.

a * 1 = a so the ‘a’ signal passes through.

a * 0 = 0 so the ‘a’ signal is suppressed.

The first example used poll, where the desired output is printed in the post window (i.e., silent) and printing occurs in response to a trigger signal. (There’s always a trigger – Poll *new1 creates a trigger for you if you didn’t provide one.) You can’t delete array / trigger → Poll, but you can suppress the trigger by multiplying by a false condition = no printed output.

In the second, the desired output is the mixdown of the oscillators. Again, you can’t delete an oscillator on the fly, but if it’s volume is 0, then it’s absent from the output.

Pass-or-suppress is a generally-useful signal processing pattern.


Indeed, and it’s shown by the fact how often this topic comes up in this or another way. Very relevant for FFT processing (bins), additive synthesing (partials), chorus fxs (voices) etc.
miSCellaneous_lib’s help file “Event patterns and array args” has some examples of this kind, with and without patterns.