Reputation: 999
I am having some trouble accessing more than two microphones usig pyaudio. I have a Scarlett 18i20 mixing device to which I want to connect several microphones (up to 8) and then capture the audio stream through pyaudio. After importing pyaudio I get the following standard input device:
In[34]:
s=pyaudio.PyAudio()
s.get_default_input_device_info()
Out[34]:
{'defaultHighInputLatency': 0.18,
'defaultHighOutputLatency': 0.18,
'defaultLowInputLatency': 0.09,
'defaultLowOutputLatency': 0.09,
'defaultSampleRate': 44100.0,
'hostApi': 0L,
'index': 1L,
'maxInputChannels': 18L,
'maxOutputChannels': 0L,
'name': u'Eingang (Scarlett 18i20 USB)',
'structVersion': 2L}
I can easily access the first two microphones using the following code:
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16,
channels=18,
rate=44100,
input=True,
frames_per_buffer=1024,
output_device_index=1)
for i in range(0, 1000):
data = stream.read(CHUNK)
frames.append(data)
stream.stop_stream()
stream.close()
p.terminate()
wf = wave.open('out.wav', 'wb')
wf.setnchannels(18)
wf.setsampwidth(p.get_sample_size(pyaudio.paInt16))
wf.setframerate(44100)
wf.writeframes(b''.join(frames))
wf.close()
I have tried to execute that code for all the different input devices available with 18 input channels. The result is always the same, I get a wav file, that contains 18 channels, however only the first two of them contain signals. The other channels are empty. The Focusrite device works fine, I can see the microphone levels through an mixing application that came with the device.
I would really appreciate any help... I am not a programming expert but I really need to get this thing to work.
Thanks!
Upvotes: 1
Views: 5832
Reputation: 999
There is quite stupid error in my question. In the code I posted I specify the output_device_index, while this should of course be the input_device_index for choosing the recording device. Playing around with different input devices I found one, for which I can record all the plugged microphones.
Upvotes: 2