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.

Since the public release of the 2.6 Linux stable kernel series, the Advanced Linux Sound Architecture (ALSA) has become the default kernel sound system. This change brings significant improvements to Linux audio and MIDI capabilities, including support for professional audio hardware, 3-D surround sound, advanced MIDI functions and software mixing or audio stream multiplexing. When combined with a kernel patched for low latency, ALSA provides resources for sound and MIDI that compare well with competing platforms and in some respects are superior to them. This is a bold claim, so let's look at ALSA to see what makes it tick.

Our Story Begins

The ALSA Project began when a young programmer named Jaroslav Kysela became frustrated with the kernel sound system's lack of full support for his Gravis Ultrasound audio/MIDI card. The Gravis card created its sounds by using sampled sounds stored in the card's memory in a file format known as PAT (patch). Banks of PAT sounds could be edited and stored by the user, as long as the user was running Microsoft Windows or Apple Mac OS. Linux, sad to say, did not provide such comprehensive resources, leaving Jaroslav with a sound card that was not fully operational.

At that time, the Linux kernel sound system was the OSS/Free system, a solid and serviceable audio/MIDI subsystem that had been with the kernel sources since the early days of Linux, thanks primarily to the pioneering work of Hannu Savolainen. Alas, OSS/Free had not kept pace with the rapidly evolving world of desktop audio production, and many sound cards either were unsupported or supported only partially, as was the case with the Gravis boards. To be fair, the OSS/Free maintainers were few; there was less organization in the general Linux audio world; and manufacturers then were, as some still are now, too secretive about their driver specifications.

It might have been possible to incorporate greater support for the Gravis cards into OSS/Free, but as Jaroslav Kysela researched the OSS/Free applications programming interface (API), he realized there was a need for a new API that could support more broadly the developments taking place with modern sound cards and digital audio interfaces. Professional and consumer-level expectations had risen, demanding support for features such as high sample rates and bit depths for professional recording, 5.1 and other 3-D/surround sound audio output arrays; multichannel digital audio I/O; and multiple MIDI I/O ports. There simply were too many advances that required fundamental changes in OSS/Free, so Jaroslav did what any truly hard-core Linux coder does: he designed a new audio/MIDI API for Linux, calling it the Advanced Linux Sound Architecture.

Designing and implementing an API that would encompass the requirements of contemporary audio is a non-trivial task, and ALSA needed many years, many programmers and many releases to attain its current status as the kernel sound system. In its earlier stages, normal users had to install the system by hand, normally as a replacement for the OSS/Free system, in order to acquire support for a card or the extended features of a card. This process included uninstalling OSS/Free and recompiling the kernel for ALSA support, at that time a decidedly non-trivial task. Nevertheless, the ranks of dedicated ALSA users grew, development flourished and eventually ALSA was incorporated into the Linux 2.5 kernel development track. Finally, with the public release of the 2.6 kernel series, ALSA became the default kernel sound system.

What Is ALSA?

The ALSA home page gives us the following information:

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

  1. Efficient support for all types of audio interfaces, from consumer sound cards to professional multichannel audio interfaces.

  2. Fully modularized sound drivers.

  3. SMP and thread-safe design.

  4. User-space library (alsa-lib) to simplify application programming and provide higher level functionality.

  5. Support for the older OSS API, providing binary compatibility for most OSS programs.

ALSA is released under the GPL (GNU General Public license) and the LGPL (GNU Lesser General Public License).

Let's look at each one of these features, restating them in language more comprehensible to a normal user.

Efficient support means that you can manage the basic and advanced features of supported sound cards easily, using ALSA tools such as a sound card configuration utility and mixer programs. Such tools are integral components of the complete ALSA installation.

Modularized sound drivers means that ALSA sound card drivers are easy to install and update. They also provide the means by which the user can control a card's available options in more detail. Later in this article, we show how you can work with a driver module to access and control features of an ALSA-supported sound card.

ALSA supports multiprocessor, or SMP, machines. Thread-safe is a programming term that indicates the services provided by the software can run concurrently in different threads without bothering each other. In a modern audio/MIDI application, thread safety is a Very Good Thing.

ALSA's user-space library provides programmers, and hence their programs, with easy access to ALSA's services, and its significance to the normal user may seem a rather slight matter. However, the ALSA library provides the interface through which applications can reach those functions, helping form a more homogeneous environment at the user level. Your programs can run more harmoniously with one another, with enhanced possibilities for connection and communication between applications.

ALSA evolved during the first phase of Linux sound support when most applications were using the OSS/Free API, so an OSS/Free compatibility layer was an immediate necessity for normal users. A large number of Linux sound applications still need OSS/Free compatibility, so ALSA provides seamless support for the older API. However, programmers should note that the older API now officially is deprecated.

______________________

Similis sum folio de quo ludunt venti.

Comments

Comment viewing options

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

alsa

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

Best,

dp

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.

Regards,

Vivek G Gite.

Illuminating

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.
Thanks.
Wilson

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!

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix