Real-time processing of multiple microphone inputs

Hello everyone, I need to figure out how to receive two or more microphone signals into the supercollider. by connecting two microphones to my sound card, SC always and only reads the microphone connected to input num. 1 and the others don’t.

I leave the code below

ServerOptions.devices;

s.options.inDevice_("Microfono (US-16x08)");
s.options.outDevice_("Cuffie (Realtek High Definition");


(
SynthDef(\glive_1,{arg outBus=0, inBus=0,
	                   gden=2, gdur=0.2, amp=0, pan=0, envbuf= -1,
	                   fadein=0.2,fadeout=1,gate=0;
	                var trig, sig, env;

	                    trig = Impulse.ar(gden);
	                    sig  = SoundIn.ar(inBus, 2);   // Segnale in ingresso
	                    sig  = GrainIn.ar(2,
		                                    trig,
		                                    gdur,
		                                    sig ! 2,   // Doppio mono
		                                    pan,
		                                    envbuf,512,amp);
	                    env = Linen.kr(gate,fadein,1,fadeout,doneAction:2);
	                Out.ar(outBus,sig * env)
          }).add
)

a = Synth(\glive_1,[\inBus,0,\outBus,0,\gden,10,\gdur,0.1,\amp,1,\gate,1]);

In your code it seems like you are only attempting to read from the first input bus as the arg inBus = 0 as a default value and you are also calling it explicitly in ‘Synth(\glive_1, [\inBus, 0…]’. What happens if you do ‘Synth(\glive_1, [\inBus, 1…]’?. If a microphone is connected to the 2nd input it should produce sound. An easy way to check if input 2 is connected:

{
	Out.ar(0, SoundIn.ar(1))
}.play

This should produce sound (watch out for the feedback if you are using speakers).

1 Like

SoundIn’s inputs are different from those of In. To get multiple channels from SoundIn, provide an array of offsets from the first hardware input: SoundIn.ar(inBus + [0, 1]).

hjh

1 Like

Thanks a lot for the advice, it helped me a lot. now, if I wanted to connect a third microphone as well, would I have to do the same thing? or put a 2 in the array?