36

I purchased a small USB sound card. My Pi recognizes the device:

$ lsusb
Bus 001 Device 004: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller

If I run alsamixer and set the audio to USB PnP Sound Device, I can hear audio through the USB sound card. To make it permanent I type:

$ sudo alsactl store

But after reboot, the default is no longer the USB sound card.

enter image description here

So then I try to see a list of playback devices:

$ aplay -l

    **** List of PLAYBACK Hardware Devices ****
  card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
  card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I edit /etc/asound.conf to look like this to set the default:

$ sudo nano /etc/asound.conf


pcm.!default {
 type hw
 card 1
 device 0
}

Do a reboot and still my default is not the USB sound card.

When I try:

$ aplay /usr/share/sounds/alsa/Front_Center.wav -D sysdefault:CARD=1

I hear sound from the USB card.

I also tried the following:

$ sudo nano /etc/modprobe.d/alsa-base.conf

change the index from -2 to 0:

options snd-usb-audio index=0

Reboot and still it did not set the default. I even commented out the line and no luck.

So how do I set the USB card as my default Audio Device?

Edit

 dpkg -s pulseaudio

Displays:

Package: pulseaudio
Status: install ok installed
Priority: optional
Section: sound
Installed-Size: 4413
Maintainer: Pulseaudio maintenance team <pkg-pulseaudio-devel@lists.alioth.debian.org>
Architecture: armhf
Multi-Arch: foreign
Version: 2.0-6
Depends: libasound2 (>= 1.0.24.1), libc6 (>= 2.13-28), libcap2 (>= 2.10), libdbus-1-3 (>= 1.1.1), libfftw3-3, libgcc1 (>= 1:4.4.0), libice6 (>= 1:1.0.0), libltdl7 (>= 2.4.2), liborc-0.4-0 (>= 1:0.4.16), libpulse0 (= 2.0-6), libsamplerate0 (>= 0.1.7), libsm6, libsndfile1 (>= 1.0.20), libspeexdsp1 (>= 1.2~beta3.2-1), libstdc++6 (>= 4.1.1), libsystemd-daemon0 (>= 31), libsystemd-login0 (>= 31), libtdb1 (>= 1.2.7+git20101214), libudev0 (>= 146), libwebrtc-audio-processing-0, libx11-6, libx11-xcb1, libxcb1, libxtst6, adduser, lsb-base (>= 3.2-13), consolekit, udev (>= 143), libasound2-plugins
Recommends: pulseaudio-module-x11, gstreamer0.10-pulseaudio, rtkit
Suggests: pulseaudio-utils, pavumeter, pavucontrol, paman, paprefs
Breaks: libltdl3 (<< 1.5.24-1)
Conffiles:
 /etc/init.d/pulseaudio 8580c855e4547e8a3c84dca96d9bbd7e
 /etc/default/pulseaudio ee26e4427d72cf16a59b1a8ce2712c66
 /etc/xdg/autostart/pulseaudio.desktop 5e19ffbe14d21702be1edd3256c4265d
 /etc/xdg/autostart/pulseaudio-kde.desktop fd20c58d32035e908a0866784e4e3511
 /etc/pulse/system.pa 408f6d6119d7afce522ab1b394709134
 /etc/pulse/default.pa a9ac2a96744beae0913865fafd3d2582
 /etc/pulse/daemon.conf 6c9e4c973cabb406beee3ec81c63fcd7
 /etc/dbus-1/system.d/pulseaudio-system.conf 69d56dc5342bf589a2e199541709a452
Description: PulseAudio sound server
 PulseAudio, previously known as Polypaudio, is a sound server for POSIX and
 WIN32 systems. It is a drop in replacement for the ESD sound server with
 much better latency, mixing/re-sampling quality and overall architecture.
 .

Then:

cat /proc/asound/modules

Displays:

 0 snd_bcm2835
 1 snd_usb_audio
PhillyNJ
  • 1,210
  • 2
  • 16
  • 28

2 Answers2

31

Turns out that the OP was thinking along the correct path with his trying

$ sudo nano /etc/modprobe.d/alsa-base.conf

and changing the index from -2 to 0 via adding options snd-usb-audio index=0 to the file. However, this wasn't working.

The correct way to do it is to add options snd-usb-audio index=0 followed by options snd_bcm2835 index=1.

Essentially what doing this is forcing the default sound module (snd_bcm2835) to be disabled while the usb sound module (snd-usb-audio) is enabled.

What I believe was previously happening with just adding options snd-usb-audio index=0 was that the snd-usb-audio module and the snd_bcm2835 were conflicting, with both being enabled.

RPiAwesomeness
  • 3,001
  • 4
  • 30
  • 51
  • Sweet! This fixed the problem for me too. I had to reboot after changing alsa-base.conf, FWIW. – Andrew Swan Nov 13 '14 at 10:49
  • @RPiAwesomeness would you mind editing or even removing this answer because for raspbian versions starting with Jessie there is a much easier way to achieve the desired results, see other answer. Also, with 'Bullseeye' it actually was not enough to add the modprobe.d configuration, but it was necessary to additionally uncomment the line referring to audio in /boot/config.txt, because otherwise index=0 was always "not available". – ernstkl May 11 '22 at 08:03
18

With Raspbian Jessie and newer (Stretch, Buster, Bullseye), changing the default audio device is simpler than it used to be.

Now, simply use this command to list your alsa-detected sound cards, and take note of the card number of your preferred device.

aplay -l

Then create/edit the alsa configuration file at ~/.asoundrc, or the system wide one at /etc/asound.conf, and paste these lines:

pcm.!default {
    type hw
    card 0
}

ctl.!default { type hw
card 0 }

changing card 0 to the card number of your sound device.

Use alsamixer to double check that the default has been set correctly.

Source:

ernstkl
  • 105
  • 3
semitones
  • 431
  • 4
  • 7
  • 1
    @Greenonline, re:my 'question' from yesterday, I really couldn't add this answer the other night, because it was community-protected and I didn't have 10 rep yet! Thanks for the friendly comment though, it helped :) – semitones Mar 28 '16 at 04:25
  • Ah ok. Thanks. I thought that this answer looked familiar... :-) – Greenonline Mar 28 '16 at 06:39
  • The accepted answer didn't work for me, but this did the trick! Thanks so much. – Twiffy Jun 08 '17 at 05:24
  • 2
    This did not work for me, I instead got it working by writing this in the asound.conf

    "pcm.!default { type plug slave { pcm "hw:1,0" } }

    ctl.!default { type hw card 1 }" From: http://www.linuxcircle.com/2013/05/08/raspberry-pi-microphone-setup-with-usb-sound-card/

    – Moulde Sep 13 '17 at 08:48
  • you saved me <3 – Radu Ursache Dec 10 '20 at 09:59