Creating a Simple Mixer (newbie question)

Hi -

I have 10 channels coming in from the audio interface. I would like to be able to have independent volume control and panning control over each one, to mix them down to stereo. I think I understand how to multiply all of the signals by an array of volume values - but I’m a little confused about how to deal with panning for each signal. Does anyone know what I should be doing differently here?

SynthDef("quickmixer",
	{|in, out, vol, pan|
		var sig;
		vol = 0.8!10;
		sig = SoundIn.ar([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
		sig = Array.fill(10, {|x| Pan2.ar(sig[x], x%2)}); 
		sig = sig * \vol.kr(0.8!10)});
		Out.ar(0, Mix.ar(sig));
}).add;

Thanks

howdy!

Pan2 expects pan values between -1 and one so you want x%2 * 2 - 1 if you want them hard L or R…

you are creating a control called vol twice - once at the top when you list the arguments in out vol and pan and then set vol to 0.8!10 and then again when you write \vol.kr(0.8!10) pick one!!

otherwise this should work!

I would probably write sig = sig.collect{|i x| Pan2.ar(i), x%2 * 2 -1} in lieu of the Array.fill but thats just a preference…

if you only want this kind of panning you could also simply write: sig = sig.clump(2) to get an Array of LR pairs.

Hi there, @semiquaver -
Thank you for finding the redundancy with the volume… The one thing with the pan, though, is that I’m not sure exactly how to “process the array” for pan values…
I’d like to set the hard panning as a default, but if I want to send new values in, I’m not sure what to do… something like this wouldn’t work, right?

		sig = sig.collect{|i, x| Pan2.ar(i), \pan[x].kr};

no you probably want to created an arrayed control explicitly. how about:

sig = Pan2.ar( sig, NamedControl.kr(\pan,  [-1,1].dup(5).flat))

then you can set all the pans later by writing .set( \pan, array-of-pans ) or set the ith controls with .seti(\pan, index, value, \pan, index value…)`

1 Like

Maybe jumping the shark a little, but if you’re mixing it using a midi controller, you’re going to have to get the mididef to write to a bus. And that bus isn’t going to be an array. Or can a multichannel bus be casted into an array? So it might be easier to have | pan1, …, pan10 | and use that to control pan and then sum everything together for a 2 channel mix.

No, for this use case it works just as well to let the mididef set values using .set or .seti messages, as presented in the solution above.