33

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
  • Question...do you have pulseaudio installed by any chance? Run dpkg -s pulseaudio to find out, it will say something like it dpkg-query: package 'pulseaudio' is not installed and no information is available if it isn't. Could you run that command and post the output? – RPiAwesomeness Jul 8 '14 at 13:28
  • Also, can you run cat /proc/asound/modules and post the output? – RPiAwesomeness Jul 8 '14 at 13:29
  • @RPiAwesomeness - Updated with the requested info. – PhillyNJ Jul 8 '14 at 22:55
  • 1
    Okay, have you tried this: options snd-usb-audio index=0 [PRESS ENTER] options snd_bcm2835 index=1? From what I can see, you're just changing the snd-usb-audio index, and the system is changing it back because it can't have two (usb and bcm2835) at the same index? – RPiAwesomeness Jul 10 '14 at 12:40
  • 2
    Yay! :D Glad to have helped, and we never had to uninstall pulseaudio! Hurrah for the internet :) – RPiAwesomeness Jul 10 '14 at 15:45
30
+50

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.

| improve this answer | |
  • No problem. Again, always glad to help :D – RPiAwesomeness Jul 10 '14 at 16:01
  • 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
  • @AndrewSwan You're welcome! Glad to help! :) – RPiAwesomeness Nov 13 '14 at 17:48
14

With Raspbian Jesse, to change 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:

| improve this answer | |
  • 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 4:25
  • Ah ok. Thanks. I thought that this answer looked familiar... :-) – Greenonline Mar 28 '16 at 6:39
  • The accepted answer didn't work for me, but this did the trick! Thanks so much. – Twiffy Jun 8 '17 at 5: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: linuxcircle.com/2013/05/08/… – Moulde Sep 13 '17 at 8:48

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