Hello all,
I have been studying Nathan’s videos (SynthDef - YouTube) and am liking the flexibility he demonstrates in Routines, but am running into a limitation. This limitation is related to too many nodes being generated/ lack of efficiency when operating at higher bpms / tempo.
In the code below, I am using a Tdef to run a Routine that plays a Synth. The Synth is referencing a Synthdef that chops up samples from a Buffer that is saved locally.
The problem I am having is that when I really crank up the bpm, far too many instances of the synth are being created and it’s causing a lot of overflow in the node tree. Please see screenshot below. Is there anything I can do to give myself more processing power, or make this more efficient? I’m not trying to really go too far- only up to 300-400pm for quick chops. Using patterns, I would do this with /dur argument and crank it to 1/32 or 1/64. Thank you!
SynthDef
SynthDef(\slice, {
arg rel = 0.001, rate = 1;
var snd, buffer;
buffer = \buffer.kr(0);
snd = PlayBuf.ar(1, buffer, BufRateScale.kr(buffer) * rate, startPos: \slice.kr(0) / 16 * BufFrames.ir(buffer));
snd = snd * Env.asr(0.001, 1, rel).ar(Done.freeSelf, \gate.kr(1));
snd = snd ! 2;
Out.ar(\out.kr(0), snd);
}).add;
)
Tdef
(
Tdef(\n,
Routine {
var s;
var bpm, beat, tatum;
var bufGroup, bufBus;
s = Server.default;
bpm = 170;
beat = 60 / bpm;
tatum = beat / 4;
loop {
var buffer, rel, rate;
16.do { |slice|
var synth;
if (slice % 4 == 0) {
buffer = [1, 2, 3].choose;
rel = [0.001];
rate = [1];
};
s.makeBundle(s.latency, {
synth = Synth(\slice, [buffer: buffer, rel: rel, rate: rate, slice: slice]);
});
tatum.wait;
s.makeBundle (s.latency, {
synth.set(\gate, 0);
});
};
};
};
).play(quant: 4);
)
Node tree after running for 20ish seconds (node looks different because I am grouping here, but functionality the same as above):