Hi, when I set a new value of a named control array, instead of replacing the array, it replaces the first array element:
(
~x = {
var seq = TDuty.ar(Dseq(\seq.kr([0.5, 0.25, 0.75]).poll, inf));
var env = Env.linen(0.01, 0.3, 0.1).ar(gate: seq);
SinOsc.ar(40.midicps * [1, 1.01]) * env;
};
)
~x.play;
~x.set(\seq, [1]);
The result is [1, 0.25, 0.75]
instead of [1]
. So it seems that set
keeps the initial array size. What would the right way to replace the array content and size?
Thank you
you can’t change the size once the synth graph is built sadly!
You can however use the reset
field in TDuty to change how much of the sequence gets played each time though (I think!)
Thank you, @semiquaver. This means that I will need to find an alternative way to sequence the synth, maybe Demand? I was looking for an equivalent of a Pattern duration: \dur, Pseq([0.5, 1], inf)
.
Not really.
Often overlooked is Pser / Dser – like Pseq / Dseq, but ‘repeats’ says how many elements of the array to use. Wrap that in an infinite-repeat looping pattern, and you’re there. In patterns, “infinite repeat” is Pn(pattern, inf)
. Demand UGens don’t have a Dn, but you can Dseq([demand units], inf)
instead.
(
SynthDef(\trigseq, { |out = 0, freq = 440, amp = 0.1, size = 4|
var durs = NamedControl.kr(\durs, Array.fill(4, 1));
var reset = NamedControl.tr(\reset, 0);
var trig = TDuty.kr(
Dseq([ // used here like Pn in pattern-land
Dser(durs, size)
], inf),
reset,
level: 1
);
var eg = Decay2.kr(trig, 0.01, 0.1);
var sig = SinOsc.ar(freq) * amp;
Out.ar(out, (sig * eg).dup);
}).add;
)
x = Synth(\trigseq, [durs: [0.25, 0.5, 0.75, 1]]);
x.set(\durs, [0.5, 0.25], \size, 2, \reset, 1);
x.free;
hjh
Very interesting approach
. We must pass durs and size, but we can automatically get the size from the array:
x.set(\durs, a = [0.5, 0.25, 0.75], \size, a.size, \reset, 1);
And it seems to work without reset:
x.set(\durs, a = [0.5, 0.25, 0.75], \size, a.size);
Thank you very much 