I am attempting to record in stereo using a pair of stereo headphones, this Stereo USB soundcard:
http://www.ebay.co.uk/itm/261343188737?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
and my laptop. I am using the USB soundcard as I eventually want to get this working on my raspberry pi. I am using pyalsaaudio and the following code:
import matplotlib
import alsaaudio, wave, numpy
inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL, 'plughw:CARD=Device')
inp.setchannels(2)
inp.setrate(44100)
inp.setformat(alsaaudio.PCM_FORMAT_S16_LE)
inp.setperiodsize(1024)
i = int(raw_input('How many samples of recording?'))
amplitude = []
while i > 0:
l, data = inp.read()
a = numpy.fromstring(data, dtype='int16')
amplitude.extend(abs(a))
i -= 1
print amplitude
I want each headphone to be a separate channels, ie. left headphone = channel 1, right headphone = channel 2 but so far I have only got what appears to be a mono recording, (when I make a sound in to jsut one headphone I get for example (245, 321, 678, 672, 478, 456) as the resulting data when I am expecting for interleaved audio data something like (245, 21, 678, 25, 567, 12) ie. a small reading from one channel and a large one from the other.
arecord -L returns:
default Playback/recording through the PulseAudio sound server
sysdefault:CARD=PCH HDA Intel PCH, ALC270 Analog Default Audio Device
front:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog Front speakers
surround40:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog 4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog 4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog 5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog Direct sample mixing device
dsnoop:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog Direct sample snooping device
hw:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0 HDA Intel PCH, ALC270 Analog Hardware device with all software conversions
sysdefault:CARD=Device USB PnP Sound Device, USB Audio Default Audio Device
front:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Front speakers
surround40:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct sample mixing device
dsnoop:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct sample snooping device
hw:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct hardware device without any conversions
plughw:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Hardware device with all software conversions
Not completely certain which of these are relevant...
PCH is the built in sound card on my laptop, Device is the USB soundcard. I am starting to doubt that the USB soundcard is actually capable of stereo recording as when I run alsamixer I cannot adjust the left and right channels for the mic individually.
On that basis I would first like to get the stereo recording working on my laptops's soundcard, but I am not sure how to specify to use the headphones plugged into the headphone/mic port on my laptop to record rather than the built in laptop mic - In general I cannot work out how to record using a specific device on a soundcard.
I am not sure quite what to try next as I am new to alsa and pyalsaaudio. Any advice on how to make this work would be appreciated.