Configuring Sound on Linux/ALSA/Troubleshooting

Errors and Solutions edit

Kernel lacks appropriate modules edit

Symptom edit

Indicated by:

  • The virtual directory /proc/asound is not present
  • The command aplay -l returns no sound cards present
  • The sound card shows up under some hardware detection mechanism, i.e., lspci

Sometimes the cause of this is selectively pulling out modules suggested by a dist-upgrade, such as the kernel, without the kernel modules.

Solution edit

Add the appropriate modules to your kernel. In Ubuntu you can upgrade to the newest kernel and modules by issuing the following command:

 $ sudo apt-get install linux-generic

Invalid card specified edit

Symptom edit

If you encounter the following error it simply means you are targeting a non-existent or erroneous device:

$ cat /dev/urandom | aplay
ALSA lib pcm_hw.c:1207:(_snd_pcm_hw_open) Invalid value for card
aplay: main:546: audio open error: No such file or directory

Solution edit

This can often be remedied by simply specifying the device explicitly.

 cat /dev/urandom | aplay -D hw:0,3

Bad sample edit

Symptom edit

This is a rather complex option . Essentially, hardware expects a certain datatype for the sound sample, and you're providing the wrong one.

 aplay: set_params:901: Sample format non available

Solution edit

Specify the sample format, or amend the rate in the ALSA conf file.

 cat /dev/urandom | aplay -f S16_LE ## Where S16_LE is your desired rate

No channel count edit

Symptom edit

If you do not provide to ALSA the amount of channels you wish to output to, you'll get the following error:

 aplay: set_params:901: Channels count non available

Solution edit

Specify the amount of channels you wish to output too. Two is considered safe for the purpose of troubleshooting.

 cat /dev/urandom | aplay -c 2 ## Two channels is stereo sound