Hi all,
I’m running into a confusing issue when passing arguments to a synth, and I’d like to understand what’s going on.
I have a simple SynthDef using PlayBuf:
(
SynthDef(\playBufTest, {
|out=0, buf|
var sig;
sig = PlayBuf.ar(
2,
buf,
BufRateScale.kr(buf),
doneAction: 2
);
Out.ar(out, sig);
}).add;
)
Buffers are loaded correctly into an Event like:
When I call the synth using an array of key-value pairs, everything works as expected:
Synth(\playBufTest, [\buf, ~buffers[\B][2]]);
But when I use an Event-style arguments syntax:
Synth(\playBufTest, (buf: ~buffers[\A][2]));
it always plays buffer 0 (i.e. the first buffer), regardless of the index or function (i.e. choose) I specify. I checked and the buffers are correctly loaded, the only thing that is changing is the way I assign the arguments.
Why does passing arguments as an Event behave differently from the Array form in this case?
Is this: expected behavior? A subtle evaluation issue? Something specific to how Events handle Buffer objects?
And more generally, is there a recommended best practice here?
Thanks a lot!