Send to multiple busses

I’m having problems with sending audio signal to multiple busses.

		~icecrush = Routine({
				 var out = {|...indices| // Accept a variable number of arguments
        if (indices.size == 1) {
            ~mixBus[indices[0]]; // Single bus selection
        }  {
            indices.collect {|index| ~mixBus[index] }; // Multiple bus selection
        }
    };

		 var reverb = {|...indices| // Accept a variable number of arguments
        if (indices.size == 1) {
            ~reverbSendBus[indices[0]]; // Single bus selection
        }  {
            indices.collect {|index| ~reverbSendBus[index] }; // Multiple bus selection
        }
    };

		 var delay = {|...indices| // Accept a variable number of arguments
        if (indices.size == 1) {
            ~delaySendBus[indices[0]]; // Single bus selection
        }  {
            indices.collect {|index| ~delaySendBus[index] }; // Multiple bus selection
        }
    };


			5.do({|icecrush|


				[3, 4, 2.5, 5, 6].collect({|i, n|
					x = Synth(\icebreak, [\freq, i, bpf: i*500, duration: rrand(5, 10), \amp, 5.dbamp, \bpf, rrand(120, 600), \shape, rrand(0.9, 2.3), \trig, rrand(0.2, 0.8),
						\fxSend1, out.(1, 5), \fxSend1vol, 0.5]);

				});

The function works as a standalone and if i write out.(1,6) it will indeed output the value ~mixBus[1] and ~mixBus[6]. But when used on that synth it’s not working at all. I only get sound on ~mixBus[1].

SynthDef(\icebreak, {
	var snd, env, duration, freqEnv, freqshift, freq, shape;
	freq = \freq.kr(2);
	shape = \shape.kr(0.1);
	duration = \duration.kr(1);
	env = Env.perc(\atk.kr(0.01), duration).ar(Done.freeSelf);
	freqEnv = Env([0.1, 0.63, 0.3, 0.2, 0.4, 0.1], [freq/2, freq, freq*1.4], curve: \sin);
	freqshift = EnvGen.kr(freqEnv, Impulse.kr(\trig.kr(0.2)));
	snd = SinOsc.ar(PinkNoise.ar(800) * freqshift) * \amp.kr(-10.dbamp);
	snd = BPF.ar(snd, \bpf.kr(300) * EnvGen.kr(Env([shape, shape/2, shape*1.3, shape*1.03, shape*1.4, shape*2, shape*1.5, shape*4], [0.1, 1, 0.5, 0.3]), Impulse.kr(20)), 0.6);
	//snd = snd + Ringz.ar(CombC.ar(snd, 0.2, 0.2), 300*freqshift * 2, 0.1, 0.03);
	snd = snd * env;



	Out.ar(\fxSend1.kr(nil), (snd*\fxSend1vol.kr(nil)));
	Out.ar(\fxSend2.kr(nil), (snd*\fxSend2vol.kr(nil)));
	Out.ar(\fxSend3.kr(nil), (snd*\fxSend3vol.kr(nil)));
	Out.ar(\fxSend4.kr(nil), (snd*\fxSend4vol.kr(nil)));
}).add;

Is it not possible to send to multiple busses in one Synth parameter?

The reason I created this setup was because I have already written tons of events and routines for a project. So I wanted to be able to do a quick change without having to rewrite all of my SynthDefs or rewrite all of my routines completely. Now I have just changed from \fxSend1, ~mixBus[1] to \fxSend1, out.(1, 5) because I want the synth to send to both ~mixBus[1] and ~mixBus[5].

Hope that someone have a simple solution that can help me solve this.

It’s possible, but the control input has to be declared for multiple values ahead of time.

You cannot define a single-value input – \fxSend1.kr will accept only a single value – and then expect it to expand to multiple channels at runtime.

The design of a SynthDef must be set in stone at the time you create it.

If you try to put two values into \fxSend1.kr, then it would have to change the one Out.ar for it into two Out.ar’s. That is not a structure that is set in stone – so, you can’t do it.

You could define an array:

Out.ar(\fxSend1.kr([-1, -1, -1, -1, -1]), ...)

… and mySynth.set(\fxSend1, [1, 5]) and I believe the -1 bus numbers will just be inactive.

The other way to do this – I’d say, best way to do this! – is to write a signal out to a single bus, and then create more synths whose only job is to read from the source bus and write to a different bus. You can add as many of those synths as you need. Then you have dynamic routing without putting dozens of Out’s into your main SynthDef that you might not use all the time.

hjh

@jamshark70
I tried doing Out.ar(\fxSend1.kr([-1, -1, -1, -1, -1]), ...) But it seems like SC then puts all non-changed outputs to output 0. Which of course is ok, if I don’t route that to a speaker.

I think I understand your “best way” and I normally do it that way. But in the situation where I am at the moment that is not possible. Too many places where I need to change the code.
I even tried to use ReplaceOut.ar(0,0) before the other Out.ar:s, but that did not work either.

Or you could use a helper function to set the bus array:

~setBuses = { |synth, key, busArray, numBuses = 5|
    synth.set(key, busArray.extend(numBuses, -1));
};

extend guarantees the new array’s size and fills out the end of the array with the given value.

hjh