How to configure different ALSA defaults for capture through one device and playback through another?

Viewed 7207

I'm looking for some help in configuring the audio on a Raspberry Pi as all my Googling efforts have fallen short so far!

My setup:

  • Raspberry PI 3 (running Debian Jessie)
  • USB WebCam (Logitech) which I'm using to capture audio
  • External speaker in 3.5mm audio jack which is used for playback

So far I've managed to configure ALSA to, by default, capture via the USB Webcam and playback via the 3.5mm jack. For example, the following works fine:

# Capture from Webcam
arecord test.wav

# Playback through 3.5mm jack
aplay test.wav

By default this captures audio in 8-bit, 8KHz, Mono. However, I'd like the default capture process to use 16-bit, 16KHz, Mono settings, and this is where I'm stuck.

Here's my working ~/.asoundrc file:

pcm.!default {

        type asym

        playback.pcm {
                type hw
                card 1
                device 0
        }

        capture.pcm {
                type plug
                slave {
                        pcm {
                                type hw
                                card 0
                                device 0
                        }
                }
        }
}

And my /etc/modprobe.d/alsa-base.conf:

options snd_usb_audio index=0
options snd_bcm2835 index=1

options snd slots=snd-usb-audio,snd-bcm2835

And the output of cat /etc/asound/cards:

 0 [U0x46d0x825    ]: USB-Audio - USB Device 0x46d:0x825
                      USB Device 0x46d:0x825 at usb-3f980000.usb-1.4, high speed
 1 [ALSA           ]: bcm2835 - bcm2835 ALSA
                      bcm2835 ALSA

I've followed various guides to set the format, rate and channels attributes without any success. For example, this didn't work:

pcm.!default {

        type asym

        playback.pcm {
                type hw
                card 1
                device 0
        }

        capture.pcm {
                type plug
                slave {
                        pcm {
                                type hw
                                card 0
                                device 0
                        }
                        format S16_LE
                        rate 16000
                        channels 1
                }
        }
}

(I've also tried moving those attribute inside the pcm block in one of many desperate attempts!)

In truth I have no experience with audio on Linux at all, and am utterly lost and any guidance would be hugely appreciated!

1 Answers
Related