Setup of busses

Hi,
I’ve been trying different solutions provided on this forum but I cant seem to figure this out.
I’m having trouble with routing.
In my project I use 6 audio busses that I send through blackhole to Max. Each bus represents a sound source. I want to assign synths in SC to these busses in a flexible way. But I also want to add effects to some of the synths sometimes.
In this example I have 3 effects. Delay, reverb and distortion. The synthdefs have the same structure for their outs:

	Out.ar(out, sig)*0.8;
	Out.ar(fxSend1, (sig*fxSend1vol));
	Out.ar(fxSend2, (sig*fxSend2vol));
	Out.ar(fxSend3, (sig*fxSend3vol));

I have a separate bus for the delay, reverb and distortion.

I guess it should look like this:

Synth1 —fxBus — fxSynth ----- Bus1
Synth2 —fxBus — FxSynth — Bus2
Synth3—fxBus — FxSynth — Bus3

But now it looks like this

Synth1 —
Synth2 —fxBus — FxSynth — [Bus1, bus 2, Bus 3]
Synth3—

The problem is that each bus receives all of the synths.
Should I have equal amount of In.ar as busses in each effect and then equal amount of Out.ar?
Is there a more simple way to do this where the synth goes through the effects and then have a mixer for each bus?

I think I know how to solve this by manually writing a lot of in:s and outs, but isn’t there a more simple way to do this?

I saw somewhere a chain that was something more like this:

Synth1 —fxBusSend1 — fxSynth ------ Bus1
Synth2 —fxBusSend2 — FxSynth — Bus2
Synth3—fxBusSend3 — FxSynth — Bus3

Think of it in terms of an audio mixer.
You can have either “insert” or “send” effects on each “channel strip” (“sound source” in your post).
Your routing is using send effects.
Any synth can send audio to an effect synth, which will process and forward all audio sent to it.
So you will have all your clean audio on respective “out” bus, plus three channels (or sets of channels) of effect audio that sum audio from the sources that send to them.

But I’m interpreting your post such that you want each sound source to have optional reverb, delay and distortion added to the output sent to Max, so that in Max you get 6 inputs with reverb etc already added to each.
So what you need are “insert” effects.
This will mean separate instances of reverb, delay and distortion for each sound source, or channel. Separate synths, on separate buses. At least I can’t think of a better way to do it.

The routing would probably be something like this:

source1 -> 
                   out1 ->
                   reverb1 ->
                   delay1 ->
                   distortion1 ->
                                          mixer1 ->
                                                            max1

You can skip the mixer and just send reverb1, delay1, distortion1 synths to the out1, which then is what you should receive in Max. It depends on how you prefer to mix. I would probably like to have a mixer synth to control the relative effects levels and maybe add something more, such as a limiter.

It’s going to be a lot of buses. Maybe draw a proper diagram to understand how all of it is connected.

First I did it your way but since one of my fx is quite CPU heavy it would be crazy to have 8 of them. Instead I did it like this. It actually works quite good, probably have to setup some more details in the mixer. Just tried to solve the reverb situation first. It is of course quite many busses but few lines of code and this is rather easy to scale up.
If someone have an idea of how to use arrays to create the arguments in the SynthDef I would appreciate it. Then I could use the same concept of iteration as I do in the mixer. So it would be very easy to scale up since the Mixer is not using that much CPU.

/// Bus setup for Fattiggården.

({
~srcGroup = Group.new;
~fxGroup = Group.after(~srcGroup);
~mixerGroup = Group.after(~fxGroup);

})

(
~maxBus = 8.collect{Bus.audio(s)}; // these go from the mixer to max.
~reverbBus = 8.collect{Bus.audio(s)}; // these go from effect to mixer
~delayBus = 8.collect{Bus.audio(s)};
~distBus = 8.collect{Bus.audio(s)};
~variousBus = 8.collect{Bus.audio(s)};
~reverbSendBus = 8.collect{Bus.audio(s)}; // these go from source to effect
~delaySendBus = 8.collect{Bus.audio(s)};
~distSendBus = 8.collect{Bus.audio(s)};
~variousSendBus = 8.collect{Bus.audio(s)};
);

(
SynthDef(\sin, {
	var snd, env;
	env = Env.perc(0.01, \duration.kr(20)).ar(Done.freeSelf);
	snd = SinOsc.ar(\freq.kr(400));
	snd = snd * env;
	snd = snd * -10.dbamp;

	Out.ar(\out.kr(0), snd);
}).add;

SynthDef(\rev, {
	|in1, in2, in3, in4, in5, in6, in7, in8, out1,out2,out3,out4,out5,out6,out7,out8| // Difficulty with scaling for more channels. 

	var in, snd, out;
	in = In.ar([in1, in2, in3, in4, in5, in6, in7, in8], 1);
	snd = FreeVerb.ar([in]);
	ReplaceOut.ar([out1,out2,out3,out4,out5,out6,out7,out8], snd);

}).add;

SynthDef(\del, {
	var in, snd;
	in = In.ar(\in.kr(0), 1);
	snd = DelayC.ar(in);
	ReplaceOut.ar(\out.kr(0), snd);
}).add;


SynthDef(\dist, {
	var in, snd;
	in = In.ar(\in.kr(0), 1);
	snd = in.tanh;
	snd = Limiter.ar(snd);
	ReplaceOut.ar(\out.kr(0), snd);
}).add;

SynthDef(\mixer, {
	var in, snd;
	in = In.ar(\in.kr(0), 1);
	snd = Limiter.ar(in, \level.kr(1));
	Out.ar(\out.kr(0), snd);
}).add;
)




~mixer = 8.do{|i|
	Synth(\mixer, [\in, [~reverbBus[i], ~delayBus[i], ~distBus[i]], \out, ~maxBus[i]], ~mixerGroup);

}; /// creates 8 mixers. 

	x = Synth(\sin, [duration: 40, out: ~reverbSendBus[0]], ~srcGroup);
s.sync;

	Synth(\rev, [
		in1: ~reverbSendBus[0],
		in2: ~reverbSendBus[1],
		in3: ~reverbSendBus[2],
		in4: ~reverbSendBus[3],
		in5: ~reverbSendBus[4],
		in6: ~reverbSendBus[5],
		in7: ~reverbSendBus[6],
		in8: ~reverbSendBus[7],
		out1: ~reverbBus[0],
		out2: ~reverbBus[1],
		out3:~reverbBus[2],
		out4:~reverbBus[3],
		out5:~reverbBus[4],
		out6:~reverbBus[5],
		out7:~reverbBus[6],
		out8:~reverbBus[7],

			], ~fxGroup);


	s.sync;

/*

Just have to do the same thing as on the reverb here.
~delay = 8.do{|i|
	Synth(\del, [\in, ~delaySendBus[i], \out, ~delayBus[i]], ~mixerGroup);

};
	s.sync;

~dist = 8.do{|i|
	Synth(\dist, [\in, ~distSendBus[i], \out, ~distBus[i]], ~mixerGroup);

};

*/


So I managed to make the Synth easier to scale up at least. But would still need help to make the SynthDef more flexible.

I’ve tried to solve it with Array.fill but then I just get a new variable and that is not possible to set inside the Synth.

This did however work to create a synth with less manual typing:

~rev = Synth(\rev, ( 8.collect { |i| 
            [ 
                ("in"++(i+1).asString): ~reverbSendBus[i], 
                ("out"++(i+1).asString): ~reverbBus[i] 
            ] 
        }.flatten
    ), 
    ~fxGroup 
);