hi all -
i am working on a synthdef with the idea that any incoming channel can simply be passed to its corresponding output channel - or it can be controlled via PanAz to pan between all 6 channels.
I’m pretty sure the following will not work, but I’m not sure what needs to change.
any advice?
~numberOfChannels = 6;
SynthDef("sum", { |bus=0, amp=1, sel=0, panArray = #[0,0,0,0,0,0]|
var sig, panned;
sig = In.ar(bus, ~numberOfChannels);
// For each input channel, optionally pan it across 6 outputs
panned = sig.collect { |chan, i|
if(panArray[i] > 0, // pan if > 0
PanAz.ar(~numberOfChannels, chan, LFDNoise1.ar(0.1)),
chan
)
};
panned = panned.sum; // sum over the 6x6 array to get 6 channels
sig = Select.ar(sel, [sig, panned]);
Out.ar(0, sig * Lag.ar(amp.asAudioRateInput, 0.5));
}).add;
It’s very close. The if is OK, as long as the true and false “branches” are signals rather than functions.
The thing that won’t work is: for each channel, you’re producing two alternatives. One is a panned multichannel array; the other is a single channel. If these are going to be merged by the conditional, they should be compatible channel arrangements.
Maybe something like this. (I’ll also introduce a different syntax for the array, so that ~numberOfChannels always agrees.)
~numberOfChannels = 6;
SynthDef("sum", { |bus=0, amp=1, sel=0|
var panArray = NamedControl.kr(\panArray, Array.fill(~numberOfChannels, 0));
var sig, panned;
sig = In.ar(bus, ~numberOfChannels);
// For each input channel, optionally pan it across 6 outputs
panned = sig.collect { |chan, i|
if(panArray[i] > 0, // pan if > 0
PanAz.ar(~numberOfChannels, chan, LFDNoise1.ar(0.1)),
Array.fill(~numberOfChannels, 0).put(i, chan)
)
};
panned = panned.sum; // sum over the 6x6 array to get 6 channels
sig = Select.ar(sel, [sig, panned]);
Out.ar(0, sig * Lag.ar(amp.asAudioRateInput, 0.5));
}).add;
(Note that the constant 0s in the non-panned version will be merged with PanAz output channels, so all the output channels will end up being audio rate.)