Avatar
Linux, plaintext & minimalism
September 30, 2019

How to select the right soundcard using ALSA

I installed Gentoo on my old media computer a few weeks ago. I use the computer with an internal soundcard called Asus Xonar DX a card that has always worked well and out of the box with Linux.

The only issue I ever encountered in regards to using an internal sound card was with ALSA getting confused and not knowing which card to use. For some reason it always chooses the PC-speaker.

To work around that issue with Arch Linux (which was what I used before Gentoo) I just blacklisted the kernel module pcspkr with the command # rmmod pcspkr and then made it permanent:

# echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf

With Gentoo that didn’t work[1], so I had to tell ALSA which card I wanted it to use. To do so I needed to figure out the name of my card, which you can do with the command aplay -L:

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=DX
    Xonar DX, Multichannel
    Default Audio Device
[...]
front:CARD=DX,DEV=0
    Xonar DX, Multichannel
    Front speakers
[...]
front:CARD=pcsp,DEV=0
    pcsp, pcsp
    Front speakers
  1. I later learned that there’s a second module for the PC-speaker called snd_pcsp. It could have worked to just disabled that as well.

As you can see, my soundcard is called DX and the device number is 0:

front:CARD=DX,DEV=0

With that I then created the file ~/.asoundrc and added this content to it:

defaults.pcm.!card DX
defaults.pcm.!device 0
defaults.pcm.!ctl DX

I then continued to reboot my computer and it all worked just fine after that.

If you want to make these changes for all users on your computer, just add the content to the file /etc/asound.conf instead.

Source: ALSA - Gentoo Wiki

Tags: ALSA | Audio