Hello all,
I am working on a Tdef again and am 90% completed with what I am trying to do. The last part of the puzzle is finding a way to modify the ‘duration’ value for each sub-array within the Routine independently. My goal is to essentially replicate the functionality of Pdefs, but without using patterns.
My current workaround is using one array within two Tdefs. But I am trying to do everything within one system.
Code overview (Tdef below):
I am using the ~synth_arg_funcs
function to store the arguments that are then passed to the Synth. I have multiple arrays within this function that create multiple Synths when the loop is iterated.
The vars declared at the start of the Routine within the Tdef are used to calculate the duration. I add duration.wait
after the Synth creation and set the gate = 0 so that n time elapses before the next Synth is created (got this technique from Nathan).
My question is- Is there any way to independently control the duration of each array?
Here is the Tdef:
// Tdef. Used for 'on the fly' changes and is (quant: 4)
(
Tdef(\test2,
Routine {
// Vars for duration
var bpm, beat, duration;
bpm = 137;
beat = 60 / bpm;
duration = beat / 2;
loop {
var i = 0;
~synth_arg_funcs = {|i| [
// Each of these sub-arrays acts like a standard Pdef. On the left is the arg and the right is the value. No limit on how many arrays you can add. Using wrapAt(i) to ensure the values loop to the start, like a Pseq.
[
patch: [~b1, ~b2].wrapAt(i),
amp: [
1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0,
1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
].wrapAt(i),
buffer: [1].wrapAt(i),
rate: [1].wrapAt(i),
atk: [0.01].wrapAt(i),
rel: [0.1].wrapAt(i),
],
[
patch: [~b1, ~b2].wrapAt(i),
amp: [
1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,
].wrapAt(i),
buffer: [1].wrapAt(i),
rate: [1].wrapAt(i),
atk: [0.01].wrapAt(i),
rel: [0.1].wrapAt(i),
],
] };
// Secondary loop. Using n = inf to cycle through infinitely
inf.do { |synth, j|
// Passing the args here as a collection
var synthArgs = ~synth_arg_funcs.(i).collect({|args|
// Creating the synth with args
Synth(\mainbuf, args: args, target: ~sources);
});
s.makeBundle(s.latency, {
// Once the synth plays, setting gate = 0
synthArgs.do { |synth| synth.set(\gate, 0) };
});
// Duration value here. Can apply math to this and randomness
duration.wait;
};
};
};
).play(quant: 4);
)
Thank you