0

I would like to record sound from 2 mic via the python modul pyaudio. The problem is that pyaudio only get the systemdefault pcm. There I could only record sound from one mic. My alsa.conf looks like:

defaults.ctl.card 1 #need to be set 1 to set usb mic to default
defaults.pcm.card 1 #need to be set 1 to set usb mic to default
defaults.pcm.device 0
defaults.pcm.subdevice -1

The Output from arecord -l:

null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
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
surround21:CARD=Device,DEV=0
    USB PnP Sound Device, USB Audio
    2.1 Surround output to Front and Subwoofer 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
sysdefault:CARD=Device_1
    USB PnP Sound Device, USB Audio
    Default Audio Device
front:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    Front speakers
surround21:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    Direct sample mixing device
dsnoop:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    Direct sample snooping device
hw:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Device_1,DEV=0
    USB PnP Sound Device, USB Audio
    Hardware device with all software conversions

And a selected output from pyaudio.Pyaudio().get_device_info_by_index:

0
bcm2835 ALSA: - (hw:0,0)
1
bcm2835 ALSA: IEC958/HDMI (hw:0,1)
2
USB PnP Sound Device: Audio (hw:1,0)
3
USB PnP Sound Device: Audio (hw:2,0)
4
sysdefault
5
front
6
surround40
7
iec958
8
spdif
9
dmix
10
default

I think the problem is that pyaudio hw1,0 and hw2,0 take. With arecord i have to take:

UsbMic1:arecord -f cd -D plughw 
UsbMic2:arecord -f cd -D plughw:1 

I have no idea to solve this strange problem. I would thank you for every single answer!

1

The only way I found to solve this problem is to use the python modul alsaaudio. Within this modul it is possible to use the pcm names.

0

You need to edit your asoundrc file to join multiple cards to one. Note that you will experience clock drift if they don't share the same clocks ... which is most likely the case with USB sound cards.

Here is an example :

pcm.quad {
    type multi
    slaves.a.pcm "hw:0,0"
    slaves.a.channels 2
    slaves.b.pcm "hw:0,1"
    slaves.b.channels 2
    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave a
    bindings.1.channel 1
    bindings.2.slave b
    bindings.2.channel 0
    bindings.3.slave b
    bindings.3.channel 1
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.