Alsa tutorial I

De wikijoan
Salta a la navegació Salta a la cerca


The Advanced Linux Sound Architecture (ALSA) provides audio and MIDI functionality to the Linux operating system. ALSA has the following significant features:

  • Efficient support for all types of audio interfaces, from consumer sound cards to professional multichannel audio interfaces.
  • Fully modularized sound drivers.
  • SMP and thread-safe design.
  • User space library (alsa-lib) to simplify application programming and provide higher level functionality.
  • Support for the older Open Sound System (OSS) API, providing binary compatibility for most OSS programs.

creat per Joan Quintana Compte, octubre 2008

Is my soundcard supported?

Dins de Edirol, trobem la UA25, però no pas la seva successora i que és la que jo tinc UA25-EX.

Testejar la targeta de so

Regla primera

Try the programs in alsa-utils package at first for testing. But above all, double-check your mixer setting before testing the sound!


In most sound cards, you'll need to unmute and adjust Master and PCM volumes. Don't forget unmute it! Some devices have additional special mixer volumes, but usually they don't have to be adjusted (unless the values get broken accidentally).

For testing the simple playback, use aplay program. Prepare a WAV file and simply run like:

$ aplay -vv somefile.wav

With the option -vv, aplay shows the verbose information of the PCM device, and a VU-peak meter during playing the file. If you want to test the secondary card, pass -Ddefault:1 in addition. It means the default PCM on the secondary card.

For testing a multi-channel PCM configuration, use speaker-test program. For testing 5.1 output, run like:

$ speaker-test -Dplug:surround51 -c6 -twav

The option -Dplug:surround51 specifies that you're using 5.1-surround configuration with the automatic-conversion layer. Without this option, the default PCM would be chosen, and usually only two channels are used (and the rest channels are dropped silently). The -c6 specifies that you use 6 channels. The last -twav is to choose the WAV output mode, where speaker-test will tell you the speaker position in a nice soft voice.


In general, recording requires more mixer set-up. For many devices (typically on-board one), you'll need to turn on Capture Switch, and raise Capture Volume. Then, choose an appropriate recording source from Capture Source.

Note that on alsamixer (and amixer), Capture Source appears often split mixer switches instead of an enum list. (It's because of the old design of alsamixer. Maybe changed in near future.) For example, you see the entry Mic in capture mode of alsamixer, which can be toggled via space key. It's basically the item of Capture Source in the driver expression.

For many on-board devices, the recording level can be quite low unless you set Mic Boost or Front Mic Boost mixer switch or volume. If you get too silent recording, check whether you have such a mixer element.

The simple way of recording-test is to use arecord. Run arecord like:

$ arecord -vv -fdat foo.wav

where -vv option means the verbose output just like aplay, -fdat means 48kHz, 2-channel, 16bit format, and the sound is recorded in the file foo.wav. It shows a VU-peak meter, so you will see usually what is being recorded. Push Ctrl-C to quit the recording; otherwise it'll continue endlessly. After finishing the recording, try to play back the file via aplay again.

Retrieved from ""

creat per Joan Quintana Compte, octubre 2008