A User's Guide to ALSA

Your Linux system's sound probably just came up and worked, which is great for games, chat or music listening. But with a little exploration, you can unlock the recording studio inside your hardware.
Basic and Advanced Desktop Configuration

My desktop system has been much easier to configure. It still is a fairly complex system, supporting one sound card—a SoundBlaster Live Value, with external MIDI adapter—the virtual MIDI module and an M-Audio Delta 66 multichannel audio interface.

As with the OPL3 synthesizer on my laptop, I must load sound data into the SBLive's EMU10k1 hardware synthesizer, using the ALSA sfxload utility to load soundfonts into the synth. This command configures my SBLive synth with a General MIDI soundfont distributed with the sound card:

sfxload 8mbgmsfx

Recently, developer Lee Revell significantly improved the ALSA driver for the Creative Labs SBLive and Audigy sound cards, unlocking much greater potential than was available through the previous drivers. Lee followed the lead of the kX Project, an open-source Windows-based project intended to open all the capabilities of the SBLive/Audigy cards, including true multichannel I/O, access to the DSP registers and support for x.1 surround sound. Lee's work greatly expands the recording and playback possibilities for inexpensive hardware, bringing even more value to Linux as a desktop music and sound workstation.

Installation and operation of the virtual MIDI driver for my desktop is exactly the same as it was for my laptop. See the appropriate section above for the details.

Channel settings for my SBLive can be made using alsamixer, but setting up my Delta 66 requires the use of the specialized envy24control mixer (Figure 4). This mixer provides access to and control of the advanced features of cards with the ice1712 chipsets, including the M-Audio Delta cards.

Figure 4. The envy24control Mixer

ALSA easily handles systems with multiple cards. The ALSA utilities usually include an option for specific card selection, as in these examples for my SBLive and Delta cards:

alsactl restore 0
alsactl restore 2
alsamixer -c 0
alsamixer -c 2

In my system, card 1 is the virtual MIDI card, which takes no channel settings and therefore has no associated mixer.

ALSA Plugins and the .asoundrc File

The ALSA plugins are utility services available through a file named .asoundrc, typically placed in your home directory. Plugin services include resampling, channel routing, sample format conversion and software volume control. Please see the ALSA Wiki notes on .asoundrc for detailed information regarding these and other ALSA plugins.

As I mentioned earlier, the default sound capability of my laptop is restricted to only one application at a time. Fortunately, ALSA provides a cool plugin called dmix, and its sole function is to provide a type of audio stream multiplexing called software mixing. Unfortunately, ALSA doesn't autodetect the need for the dmix plugin, so the user must prepare the necessary components.

Here is the .asoundrc for my laptop:

pcm.!default {
        type plug
        slave.pcm "dmixer"

pcm.dmixer  {
        type dmix
        ipc_key 1024
        slave {
            pcm "hw:0,0"
            period_time 0
            period_size 1024
            buffer_size 4096
            rate 32000
        bindings {
            0 0
            1 1

pcm.dsp {
        type plug
        slave.pcm "dmixer"

ctl.dmixer {
        type hw
        card 0

This file defines a new PCM device named dmixer, of the plugin type dmix, which is slaved to the PCM capabilities of the sound chip. The plugin also lets me tailor the sample rate to the capabilities of my hardware, easing CPU demands.

With the dmix plugin I can run an audio player and a video player at the same time. In case you're wondering why I might want to do such a thing, consider that I often study t'ai chi videos available on DivX discs. The video is usually wonderful, but the background music isn't always to my liking, so it's nice to be able to listen to something more to my taste. The following commands launch Andy Lo A Fo's neat alsaplayer soundfile player and the MPlayer video player:

mplayer -ao alsa9:dmixer -aop list=volume:volume=0 \
  -framedrop foo.avi
alsaplayer -o alsa -d plug:dmixer cool-foo.mp3

The video player's audio output is negated, thanks to MPlayer's software volume control, while the alsaplayer plays my preferred music. Very cool stuff, courtesy of the dmix plugin.

I have no special needs on my desktop system, but I've configured my .asoundrc file for basic accommodations for the SBLive and the Delta 66:

pcm.emu10k1 {
        type hw
        card 0

ctl.emu10k1 {
        type hw
        card 0

pcm.Delta66 {
        type hw
        card 2

ctl.Delta66 {
        type hw
        card 2

pcm.DeltaPlug {
        type plug
        card 2

ctl.DeltaPlug {
        type plug
        card 2

pcm.DeltaPlugHW {
	type plughw
	card 2

ctl.DeltaPlugHW {
        type plughw
        card 2

The card numbering reflects the ordering list when I query /proc/asound:

$ cat /proc/asound/cards
0 [Live           ]: EMU10K1 - Sound Blaster Live!
                     Sound Blaster Live! (rev.8) at 0xd000, irq 3
1 [VirMIDI        ]: VirMIDI - VirMIDI
	             Virtual MIDI Card 1
2 [M66            ]: ICE1712 - M Audio Delta 66
	             M Audio Delta 66 at 0xd800, irq 5

ALSA does not provide a default .asoundrc file, nor is it an absolute necessity. However, many interesting ALSA features are accessible only through .asoundrc, and the reader is advised to study the example files found on the ALSA Web site.

For an advanced example, see Timo Sivula's El Cheapo HOWTO, a rather amazing hardware/software hack that allows sample-accurate multichannel recording using two or more consumer-grade sound cards (Timo used the Creative Labs PCI128). Under normal circumstances, such an approach would be doomed to fail from inherent instabilities between the clock crystals of the cards, but Timo's hardware modifications and the capabilities of .asoundrc make it possible. The El Cheapo HOWTO is not for the faint of heart, but it does succeed at providing an inexpensive path to high-quality multichannel recording on the Linux desktop.


Similis sum folio de quo ludunt venti.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Anonymous's picture

can u plz tell me the modules and directories reqired to capture & play the sound....

You seem to confuse OSS

Anonymous's picture

You seem to confuse OSS (Open Sound System) with Open Source Software (as used in the term "OSS/Free software"), which leads to a rather surrealist "Our Story Begins" section. ALSA is as free as OSS was (and is)!

fool, the Open Sound System

Anonymous's picture

fool, the Open Sound System was known as OSS/Free because 4Front had decided to close source OSS, as 4Front moved ahead with OSSv4 development (which was not free) people were only left with OSSv3, which was dubbed OSS/Free to avoid confusion between the two differently licensed versions. get it?

PS: (OSSv4.2 is kickass, ALSA is bloated and under documented.)

Sales force automation example

Abu's picture

Keep the good works comming.
I am from African and also now am reading in English, give true I wrote the following sentence: "As based in this sensor, an specialty case' cogs any building for the brand or rental of cost whereby a drug includes a athletic layout for the email to reduce prototyper for cloning one or more similar positions into interest in the region or for the drug to create part when a response developed by the communication includes a many killing."

Thank you very much ;). Abu.

ALS120 ISA Soundcard under Linux (EPC-SALS12.01 Vers 2.0 )

Christian1000's picture

Hi, I am trying to activate the above named card with my current Linux system (Ubuntu 9.04 ) but it does not work. Can you give some advice?

Author's reply

Dave Phillips's picture

Have you tried this command:

sudo modprobe snd-als100



Similis sum folio de quo ludunt venti.

Very nice and informative for beginners

vivek's picture

Even experienced user like me find it useful, especially Linux Laptop MIDI System part. I’m also recommending this to all my user group members.


Vivek G Gite.


wcoltters's picture

Very exciting article from beginning to end!
I'm new to Linux Audio but not to Linux. I'm educating myself with all the information I can get, and your articles are of great help to setup my personal home studio.

about alsa and multiple cards

Will Morrison's picture

Great article, all in all. I am in a bit of a quandry with ALSA vs OSS, as I am trying to use 2 Delta 1010lt cards in one machine and have them function as one card. According to the OSS people, you can use up to 4 of this card in one machine this way, but I can't find anything in the ALSA docs that says "Yes, here is how it works and how to do it".

ALSA has come a long, long way in the last few years, but it still has a way to go (but don't we all). I do applaud those who have done such good work. Ardour with the 1010lt is great! Jamin is also wonderful, and things just keep getting better. Thanks to all for their work!