1

I want to record void with an USB microphone on a Raspberry PI running Raspbian (Jessie). At the same time, I want to keep the audio output on the internal sound card. Similar questions on this site do not include a useful answer.

Card indices:

pi@raspberrypi:~ $ cat /proc/asound/modules 
 0 snd_bcm2835
 1 snd_usb_audio

alsa.conf:

pi@raspberrypi:~ $ cat /usr/share/alsa/alsa.conf | grep '.card '
defaults.ctl.card 0
defaults.pcm.card 0

~/.asoundrc:

pi@raspberrypi:~ $ cat ~/.asoundrc
pcm.!default {
    type hw
    card 0
}

ctl.!default {
    type hw
    card 0
}

Now when I set the cards in both configuration files to 1, I can record audio with the command arecord temp.wav --format=S16_LE. However, I can’t play it, since the microphone card that’s currently configured has no output.

How do I configure the system in a way, that only the input is taken from the microphone card with index 1?

I tried setting ctl.card to 1 while leaving pcm.card as 0 and also changed the card values in .asoundrc accordingly. Recording audio looks on card 0 still.

2 Answers 2

1

Since December 2020, Pulse is added to stock Raspberry Pi OS, so you could just upgrade your system and select default input and output devices (called sink and source respectively) in PulseAudio Volume Control settings.

0

We have solved this problem on the Audio Injector forum, on a thread with the topic "Sharing the input". The solution is to make an asym pcm device which defines different playback and capture devices.

Generally speaking because the closks of the Pi's audio system and the USB's audio system are slightly different, you will probably have to use the dmix and dsnoop plugin, or one of them.

An example .asoundrc is:

pcm.!default {
    type asym
    playback.pcm "dmixplug"
    capture.pcm "dsnoopplug"
}

ctl.custom
{
    type hw
    card 0
}

pcm.dmixplug {
  type plug
  slave.pcm "dmix"
}

pcm.dsnoopplug {
  type plug
  slave.pcm "dsnoop:1,0"
}

If I am not mistaken, this will record from card 1 and play through card 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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