Control the gain of each individual orbit from an external controller

Hello everyone :musical_note: :drum: :robot:

I was doing some upgrades to my live coding environment for an upcoming gig and tought it would be useful to control the volume of each orbit individually from a control surface. Sometimes it happens that somethings drops in too loud or maybe you just want to do a quick fade in and in all these cases having a good old fader comes pretty handy.

So this is the SC code I wrote, pretty basic stuff, but it works well. It would be nice to hear what you people think and if you have any advice on how to improve the code (shorter and readable syntax), add some features (I was thinking of a simple eq maybe?), or if there is a way to achieve the same result in a more efficient or simple way.

PS
I am using TouchOSC to control the volume of each orbit from my phone

(
//create a bus for each orbit
~bus0 = Bus.audio(s, numChannels:2);
~bus1 = Bus.audio(s, numChannels:2);
~bus2 = Bus.audio(s, numChannels:2);
~bus3 = Bus.audio(s, numChannels:2);
~bus4 = Bus.audio(s, numChannels:2);
~bus5 = Bus.audio(s, numChannels:2);

//route each orbit into a bus
~dirt.orbits[0].outBus = ~bus0;
~dirt.orbits[1].outBus = ~bus1;
~dirt.orbits[2].outBus = ~bus2;
~dirt.orbits[3].outBus = ~bus3;
~dirt.orbits[4].outBus = ~bus4;
~dirt.orbits[5].outBus = ~bus5;


// control the gain with an Ndef
Ndef(\gainCtrl0, {|amp=1|
	var dirt = InBus.ar(~bus0, 2);
	dirt * amp;
}).play;

Ndef(\gainCtrl1, {|amp=1|
	var dirt = InBus.ar(~bus1, 2);
	dirt * amp;
}).play;

Ndef(\gainCtrl2, {|amp=1|
	var dirt = InBus.ar(~bus2, 2);
	dirt * amp;
}).play;

Ndef(\gainCtrl3, {|amp=1|
	var dirt = InBus.ar(~bus3, 2);
	dirt * amp;
}).play;

Ndef(\gainCtrl4, {|amp=1|
	var dirt = InBus.ar(~bus4, 2);
	dirt * amp;
}).play;

Ndef(\gainCtrl5, {|amp=1|
	var dirt = InBus.ar(~bus5, 2);
	dirt * amp;
}).play;

// control the Ndef with OSC
OSCdef.new(
	\orbitGain0,
	{|msg, time, addr, port|
		// msg[1].postln;
		Ndef(\gainCtrl0).set(\amp, msg[1]);
	};
	,"/1/f1"
);
OSCdef.new(
	\orbitGain1,
	{|msg, time, addr, port|
		// msg[1].postln;
		Ndef(\gainCtrl1).set(\amp, msg[1]);
	};
	,"/1/f2"
);
OSCdef.new(
	\orbitGain2,
	{|msg, time, addr, port|
		// msg[1].postln;
		Ndef(\gainCtrl2).set(\amp, msg[1]);
	};
	,"/1/f3"
);
OSCdef.new(
	\orbitGain3,
	{|msg, time, addr, port|
		// msg[1].postln;
		Ndef(\gainCtrl3).set(\amp, msg[1]);
	};
	,"/1/f4"
);
OSCdef.new(
	\orbitGain4,
	{|msg, time, addr, port|
		// msg[1].postln;
		Ndef(\gainCtrl4).set(\amp, msg[1]);
	};
	,"/1/f5"
);
OSCdef.new(
	\orbitGain5,
	{|msg, time, addr, port|
		// msg[1].postln;
		Ndef(\gainCtrl5).set(\amp, msg[1]);
	};
	,"/1/f6"
);
)
2 Likes