Hi all,
Today I encountered some code that behaved in a way I wasn’t able to explain, related to order of execution of server nodes.
Below, the first chunk of code behaves in a way that seems predictable and normal to me. If the reverb node is after the source node, all is well. If \addAfter
is replaced with \addBefore
, the nodes are in the wrong order, and signal is not passed to hardware.
In the second chunk of code, I am declaring an audio rate argument named in
instead of using In.ar
, and I’m using .asMap
so that the value of ‘in’ is read from a private audio bus. I had always assumed this is just a different way of doing the same thing. But, interestingly, the second chunk of code works, regardless of node order.
Can anyone explain why node order doesn’t seem to be significant in the second case?
Eli
(
s.newBusAllocators;
~bus = Bus.audio(s, 1);
SynthDef(\sin, {
var sig = SinOsc.ar(\freq.kr(1000), mul: 0.2);
sig = sig * Env.perc(0.001, 0.3).ar(0, Impulse.kr(0.5));
Out.ar(\out.kr(~bus), sig);
}).add;
SynthDef(\rev, {
var sig = In.ar(\in.kr(~bus), 1);
sig = FreeVerb.ar(sig, 0.4, 0.999, 0.7);
Out.ar(\out.kr(0), sig);
}).add;
)
(
s.bind({
~src = Synth(\sin, [out: ~bus]);
~fx = Synth(\rev, [in: ~bus, out: 0], ~src, \addAfter);
// ^^^ change to \addBefore and signal flow fails
});
)
/*------------------------*/
(
s.newBusAllocators;
~bus = Bus.audio(s, 1);
SynthDef(\sin, {
var sig = SinOsc.ar(\freq.kr(1000), mul: 0.2);
sig = sig * Env.perc(0.001, 0.3).ar(0, Impulse.kr(0.5));
Out.ar(\out.kr(~bus), sig);
}).add;
SynthDef(\rev, {
var sig = FreeVerb.ar(\in.ar(0), 0.4, 0.999, 0.7);
Out.ar(\out.kr(0), sig);
}).add;
)
(
s.bind({
~src = Synth(\sin, [out: ~bus]);
~fx = Synth(\rev, [in: ~bus.asMap, out: 0], ~src, \addAfter);
// ^^^ change to \addBefore and signal flow is fine
});
)