I am using python 3 and with alsaaudio I read data from microphone but I have to work with each channel separately. So is there a way how to get data just from one channel? Or how to parse data from each channel separately?
import wave
import sys
import threading
import time
import os
import alsaaudio, audioop
# Input
inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE,alsaaudio.PCM_NONBLOCK)
inp.setchannels(2)
inp.setrate(8000)
inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
inp.setperiodsize(80)
# Output file
output = wave.open("test2.wav",'wb')
output.setnchannels(2)
output.setsampwidth(2)
output.setframerate(8000)
while True:
l,frames = inp.read()
if l>0:
print(frames)
output.writeframes(frames)