Hi guys,
To reduce some redundancy in my code, I would like my SynthDefs to be compatible both with a stereo and octophonic setup. I would like to instantiate a new synth from time to time selecting which “mode” it will work (stereo or octophonic) via a parameter.
I’ve tried with something like that:
SynthDef(\test_synth, {
|out=0, amp=0.5, pan=0.0, width=2, mode=\stereo|
var sig = SinOsc.ar(440) * amp;
if( mode == \stereo, {
Out.ar(out, Pan2.ar(sig, pan));
}, {
Out.ar(out, PanAz.ar(8, sig, pan, width:width));
});
}).add;
But it doesn’t seem to work
I’ve also tried the following way (using an , say “nchans” parameter) but I think the SynthDef cannot compile because PanAz
is expectiong to know the number of channels it will use in advance instead of at running time.
SynthDef(\test_synth, {
|out=0, amp=0.5, pan=0.0, width=2, nchans=2|
var sig = SinOsc.ar(440) * amp;
Out.ar(out, PanAz.ar(nchans, sig, pan, width:width));
}).add;
Is there some way to add this feature?
Thank you so much for your help, as always.