22

Does anyone know how to change the sound card boot priority?

All tutorials are telling me to edit /etc/modprobe.d/alsa-base.conf, but the file is missing in Raspbian Jesse.

8 Answers8

24

If you don't need the onboard audio chip (i.e. for the 3.5mm analog output or HDMI audio output), disable it and then the external USB audio device (i.e. headset) will become the primary audio device.

These steps worked on Raspbian Jessie:

  1. Disable onboard audio:
  • Open /etc/modprobe.d/raspi-blacklist.conf and add blacklist snd_bcm2835.
  1. Allow the USB audio device to become the default device:
  • Open /lib/modprobe.d/aliases.conf and comment out the line options snd-usb-audio index=-2.
  1. Reboot:
  • $ sudo reboot
  1. Test it:
  • $ aplay /usr/share/sounds/alsa/Front_Center.wav
11

The file you're looking for is located in /usr/share/alsa/alsa.conf. It's not called alsa-base.conf, just alsa.conf.

All the relevant text is in that file. Just run sudo nano /usr/share/alsa/alsa.conf, change the default sound card to 1 or whatever you prefer (obviously, 0 is default so not that one). I also deleted the # from the line that says... load card-specific configuration files (on request) and now I have the sound coming from my cirrus audio card running Debian 8 Jessie on ras pi2.

Pang
  • 1,017
3

I had problems with this on recent versions of Raspbian (Jessie).

There is a file called aliases.conf in /lib/modprobe.d which contains the line options snd-usb-audio index=-2. That line overrides the /etc/modprobe.d/ files, so you need to change that one. Comment out with a # the line options snd-usb-audio index=-2

In /usr/share/alsa/alsa.conf I un-commented “load card-specific configuration files (on request)” and I also replaced the content of .asoundrc which is a hidden file in your home folder with:

pcm.!default plughw:Device
ctl.!default plughw:Device

The downside of this solution is the desktop sound applet won't appear. So to control volume use the alsamixer application or physical sound level buttons on the USB sound dongle.

References for this:

  1. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=124016&p=857433&hilit=usb+audio#p857433
  2. http://alsa.opensrc.org/Asoundrc#Default_PCM_device.
3

I wasn't satisfied with the previous answers giving a bit ambiguous instructions, so I figured I would document a more clear solution.

A good post here shows how to test which device and card you are seeking to use.

Find your hardware device number and card number using aplay -l before and after pluggin your usb device in.

For my system, the usb device is listed as card 1: CODEC [USB Audio CODEC], device 0 ...

You can confirm the device is working with

aplay -D hw:1,0 InsertYourWavFileHere.wav

Make sure to copy a valid wav audio file into your current directory and rename appropriately. If this works, then you can hardcode these values such that they will become defaults for aplay among all other audio handled by alsa (most cases)

To edit your default values you alsa config file as others have stated:

sudo nano /usr/share/alsa/alsa.conf

The specific lines you will want to change are a few pages down. You can search with Cntl+W or just scroll down.

Change:

defaults.pcm.card 0 defaults.pcm.device 0

To:

defaults.pcm.card 1 defaults.pcm.device 0

Save the config file by pressing control+x, then nano will ask you to confirm your edits and you press Y and Enter.

topher217
  • 391
2

The method described here at the Raspberry Pi StackExchange worked for me. I am running Raspian Jessie.

The new piece of information was that I had to create a new .conf file and not edit /usr/share/alsa/alsa.conf:

To reorder my cards, I first create a file named /etc/modprobe.d/alsa base.conf. It can be named anything you want as long as it ends with .conf. I then added the following:

# This sets the index value of the cards but doesn't reorder.
options snd_usb_audio index=0   
options snd_bcm2835 index=1

# Does the reordering.
options snd slots=snd_usb_audio,snd_bcm2835
Lennart
  • 21
1

I've given a full writeup here that covers all of the above and much more. Including clearing up some misconceptions and pitfalls in the ALSA config files.

The relevant essential is to disable the Broadcom audio module called snd_bcm2835 and make sure that snd_usb_audio is loaded fist and only. This can be done in either of 2 ways.

  • In the /boot/config.txt file
  • In the module blacklist file.

Then set you ALSA config to point to the snd_usb_audio index.

not2qubit
  • 2,651
  • 4
  • 34
  • 45
0

After change alsa.conf (defaults.ctl.card 1 defaults.pcm.card 1) and (load card-specific configuration files (on request)) you have to modify your asoundrc file and put in:

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

It will be ok

scai
  • 1,100
-1

I have tried lots of people's suggestions for config changes. Kodi continued to put audio out to hdmi. I finally found that Kodi has a setting in System | Audio which allows you to choose which audio card to output to! So obvious once you see it.