i have not been able to route the output of the fx back into the main SynthDef. So i thought i could split source, fx and the final output stage with the panning and summing into three SynthDefs:
(
~numChannels = 5;
SynthDef(\multiChannelGrains, {
[...]
OffsetOut.ar(\trigOut.kr(0), arrayOfTriggers);
OffsetOut.ar(\windowOut.kr(0), arrayOfWindows);
OffsetOut.ar(\grainOut.kr(0), arrayOfGrains);
}).add;
SynthDef(\fxPerGrain, {
var arrayOfTrigs = In.ar(\trigIn.kr(0), ~numChannels);
var arrayOfWindows = In.ar(\windowIn.kr(0), ~numChannels);
var arrayOfGrains = In.ar(\grainIn.kr(0), ~numChannels);
[...]
OffsetOut.ar(\fxOut.kr(0), sig);
}).add;
SynthDef(\panPerGrain, {
var sig, arrayOfFxGrains;
arrayOfFxGrains = In.ar(\fxIn.kr(0), ~numChannels);
arrayOfFxGrains = PanAz.ar(2, arrayOfFxGrains, \pan.kr(0));
sig = arrayOfFxGrains.sum;
OffsetOut.ar(\out.kr(0), sig);
}).add;
)
// create groups and busses
(
~makeBusses = {
~bus = Dictionary.new;
~bus.add(\trigOut -> Bus.audio(s, ~numChannels) );
~bus.add(\windowOut -> Bus.audio(s, ~numChannels) );
~bus.add(\grainOut -> Bus.audio(s, ~numChannels) );
~bus.add(\fxOut -> Bus.audio(s, ~numChannels) );
};
~makesBusses.();
)
(
~makeGroups = {
~synthGrp = Group.new;
~fxGrp = Group.new(~synthGrp, \addAfter);
~finalGrp = Group.new(~fxGrp, \addAfter);
};
~makeGroups.();
)
// routing to busses
(
Routine {
s.bind {
Synth(\multiChannelGrains, [
\trigOut, ~bus[\trigOut],
\windowOut, ~bus[\windowOut],
\grainOut, ~bus[\grainOut],
], target: ~synthGrp);
};
s.bind {
Synth(\fxPerGrain, [
\trigIn, ~bus[\trigOut],
\windowIn, ~bus[\windowOut],
\grainIn, ~bus[\grainOut],
\fxOut, ~bus[\fxOut],
], target: ~fxGrp);
};
s.bind {
Synth(\panPerGrain, [
\fxIn, ~bus[\fxOut],
\out, 0,
], target: ~finalGrp);
};
}.play;
)
what do you think of this approach?