Advanced Linux Sound Architecture

Last updated
ALSA
Original author(s) Jaroslav Kysela [1]
Developer(s) ALSA team [2]
Initial release1998;26 years ago (1998)
Stable release
1.2.12 [3] / 10 June 2024;34 days ago (10 June 2024)
Written in C [4]
Operating system Linux
Type
License
Website alsa-project.org
The Linux API is composed out of the System Call Interface of the Linux kernel, the GNU C Library (by GNU), libdrm, libalsa and libevdev (by freedesktop.org). Linux API.svg
The Linux API is composed out of the System Call Interface of the Linux kernel, the GNU C Library (by GNU), libdrm, libalsa and libevdev (by freedesktop.org).
ALSA is part of the Linux kernel, while PulseAudio is middleware, a part of the lower levels of the desktop stack. So is SDL. Linux kernel and gaming input-output latency.svg
ALSA is part of the Linux kernel, while PulseAudio is middleware, a part of the lower levels of the desktop stack. So is SDL.

Advanced Linux Sound Architecture (ALSA) is a software framework and part of the Linux kernel that provides an application programming interface (API) for sound card device drivers.

Contents

Some of the goals of the ALSA project at its inception were automatic configuration of sound-card hardware and graceful handling of multiple sound devices in a system. ALSA is released under GPL-2.0-or-later and LGPL-2.1-or-later. [5]

On Linux, sound servers, like sndio, PulseAudio, JACK (low-latency professional-grade audio editing and mixing) and PipeWire, and higher-level APIs (e.g OpenAL, SDL audio, etc.) work on top of ALSA and its sound card device drivers. ALSA succeeded the older Linux port of the Open Sound System (OSS).

History

The project to develop ALSA was led by Jaroslav Kysela, and was based on the Linux device driver for the Gravis Ultrasound sound card. It started in 1998 and was developed separately from the Linux kernel until it was introduced in the 2.5 development series in 2002 (2.5.4–2.5.5). [6]

In the 2.6 version, it replaced the previous system, Open Sound System (OSS), by default (although a backwards-compatibility layer does exist). [7]

ALSA has a larger and more complex API than OSS, so it can be more difficult to develop an application that uses ALSA as its sound technology. While ALSA may be configured to provide an OSS emulation layer, such functionality is no longer available or is not installed by default in many Linux distributions.

Features

ALSA was designed with some features which were not, at the time of its conception, supported by OSS:

Besides the sound device drivers, ALSA bundles a user-space library for application developers who want to use driver features through an interface that is higher-level than the interface provided for direct interaction with the kernel drivers. Unlike the kernel API, which tries to reflect the capabilities of the hardware directly, ALSA's user-space library presents an abstraction that remains as standardized as possible across disparate underlying hardware elements. This goal is achieved in part by using software plug-ins; for example, many modern sound cards or built-in sound chips do not have a "master volume" control. Instead, for these devices, the user space library provides a software volume control using the "softvol" plug-in, and ordinary application software need not care whether such a control is implemented by underlying hardware or software emulation of such underlying hardware.

Applications

Additional to the software framework internal to the Linux kernel, the ALSA project also provides the command-line tools [8] [9] [10] and utilities [11] alsactl, [12] amixer, [13] arecord/aplay and alsamixer , [13] an ncurses-based TUI.

There also are GUIs programmed by third-party developers, such as GNOME-ALSAmixer [14] (using GTK), Kmix, [14] XFCE4-mixer, LXpanel, QasHctl, QasMixer, Pavucontrol, AconnectGUI, [15] tapiir, [15] polarbear, [15] ALSAmixerGUI [16] (using FLTK), ZynAddSubFX, Yoshimi, and even more.

Concepts

This section provides an overview of basic concepts pertaining to ALSA. [17] [18] [19]

Typically, ALSA supports up to eight cards, numbered 0 through 7; each card is a physical or logical kernel device capable of input and output. Furthermore, each card may also be addressed by its id, which is an explanatory string such as "Headset" or " ICH9".

A card has devices, numbered starting at 0; a device may be of playback type, meaning it outputs sound from the computer, or some other type such as capture, control, timer, or sequencer ; [20] device number 0 is used by default when no particular device is specified.

A device may have subdevices, numbered starting at 0; a subdevice represents some relevant sound endpoint for the device, such as a speaker pair. If the subdevice is not specified, or if subdevice number −1 is specified, then any available subdevice is used.

A card's interface is a description of an ALSA protocol for accessing the card; possible interfaces include: hw, plughw, default, and plug:dmix. The hw interface provides direct access to the kernel device, but no software mixing or stream adaptation support. The plughw and default enable sound output where the hw interface would produce an error.

An application typically describes sound output by combining all of the aforementioned specifications together in a device string[ citation needed ], which has one of the following forms (which are case-sensitive):

An ALSA stream is a data flow representing sound; the most common stream format is PCM that must be produced in such a way as to match the characteristics or parameters of the hardware, including:

Implementations

The ALSA System on Chip (ASoC) layer aims to provide better support for ALSA on embedded systems that use a system-on-chip (SoC) design. [21]

Open Sound System version 4 is able to emulate ALSA. [22]

QNX uses a sound system derived from, but not directly compatible with ALSA. The header file and library names are still "asound", same as the ALSA names. [23] ALSA API uses ioctl() calls in a way not allowed in the QNX kernel. [24]

See also

Related Research Articles

<span class="mw-page-title-main">Device driver</span> Software interface to attached devices

In the context of an operating system, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabling operating systems and other computer programs to access hardware functions without needing to know precise details about the hardware being used.

<span class="mw-page-title-main">Sound card</span> Expansion card that provides input and output of audio signals

A sound card is an internal expansion card that provides input and output of audio signals to and from a computer under the control of computer programs. The term sound card is also applied to external audio interfaces used for professional audio applications.

<span class="mw-page-title-main">QNX</span> Real-time operating system (RTOS) software

QNX is a commercial Unix-like real-time operating system, aimed primarily at the embedded systems market.

<span class="mw-page-title-main">Windowing system</span> Software that manages separately different parts of display screens

In computing, a windowing system is a software suite that manages separately different parts of display screens. It is a type of graphical user interface (GUI) which implements the WIMP paradigm for a user interface.

The Open Sound System (OSS) is an interface for making and capturing sound in Unix and Unix-like operating systems. It is based on standard Unix devices system calls. The term also sometimes refers to the software in a Unix kernel that provides the OSS interface; it can be thought of as a device driver for sound controller hardware. The goal of OSS is to allow the writing of sound-based applications that are agnostic of the underlying sound hardware.

JACK Audio Connection Kit is a professional sound server API and pair of daemon implementations to provide real-time, low-latency connections for both audio and MIDI data between applications. JACK was developed by a community of open-source developers led by Paul Davis and has been a key piece of infrastructure and the de facto standard for professional audio software on Linux since its inception in 2002. The server is free software, licensed under GPL-2.0-or-later, while the library is licensed under LGPL-2.1-or-later.

freedesktop.org (fd.o), formerly X Desktop Group (XDG), is a project to work on interoperability and shared base technology for free-software desktop environments for the X Window System (X11) and Wayland on Linux and other Unix-like operating systems. Although freedesktop.org produces specifications for interoperability, it is not a formal standards body.

<span class="mw-page-title-main">Digital audio workstation</span> Electronic device or application software used for recording, editing and producing audio files

A digital audio workstation is an electronic device or application software used for recording, editing and producing audio files. DAWs come in a wide variety of configurations from a single software program on a laptop, to an integrated stand-alone unit, all the way to a highly complex configuration of numerous components controlled by a central computer. Regardless of configuration, modern DAWs have a central interface that allows the user to alter and mix multiple recordings and tracks into a final produced piece.

<span class="mw-page-title-main">OpenAL</span> API for rendering audio

OpenAL is a cross-platform audio application programming interface (API). It is designed for efficient rendering of multichannel three-dimensional positional audio. Its API style and conventions deliberately resemble those of OpenGL. OpenAL is an environmental 3D audio library, which can add realism to a game by simulating attenuation, the Doppler effect, and material densities.

DirectSound is a deprecated software component of the Microsoft DirectX library for the Windows operating system, superseded by XAudio2. It provides a low-latency interface to sound card drivers written for Windows 95 through Windows XP and can handle the mixing and recording of multiple audio streams. DirectSound was originally written for Microsoft by John Miles.

A sound server is software that manages the use of and access to audio devices. It commonly runs as a background process.

The Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for interfacing with GPUs of modern video cards. DRM exposes an API that user-space programs can use to send commands and data to the GPU and perform operations such as configuring the mode setting of the display. DRM was first developed as the kernel-space component of the X Server Direct Rendering Infrastructure, but since then it has been used by other graphic stack alternatives such as Wayland and standalone applications and libraries such as SDL2 and Kodi.

<span class="mw-page-title-main">Linux kernel interfaces</span> An overview and comparison of the Linux kernel API and ABI.

The Linux kernel provides multiple interfaces to user-space and kernel-mode code that are used for varying purposes and that have varying properties by design. There are two types of application programming interface (API) in the Linux kernel:

  1. the "kernel–user space" API; and
  2. the "kernel internal" API.
<span class="mw-page-title-main">PulseAudio</span> Sound server for Unix-like operating systems

PulseAudio is a network-capable sound server program distributed via the freedesktop.org project. It runs mainly on Linux, including Windows Subsystem for Linux on Microsoft Windows and Termux on Android; various BSD distributions such as FreeBSD, OpenBSD, and macOS; as well as Illumos distributions and the Solaris operating system. It serves as a middleware in between applications and hardware and handles raw PCM audio streams.

This article describes audio APIs and components in Microsoft Windows which are now obsolete or deprecated.

A Bluetooth stack is software that is an implementation of the Bluetooth protocol stack.

<span class="mw-page-title-main">Kernel-based Virtual Machine</span> Virtualization module in the Linux kernel

Kernel-based Virtual Machine (KVM) is a free and open-source virtualization module in the Linux kernel that allows the kernel to function as a hypervisor. It was merged into the mainline Linux kernel in version 2.6.20, which was released on February 5, 2007. KVM requires a processor with hardware virtualization extensions, such as Intel VT or AMD-V. KVM has also been ported to other operating systems such as FreeBSD and illumos in the form of loadable kernel modules.

<span class="mw-page-title-main">Ubuntu Studio</span> Derivative of the Ubuntu operating system

Ubuntu Studio is a recognized flavor of the Ubuntu Linux distribution, which is geared to general multimedia production. The original version, based on Ubuntu 7.04, was released on 10 May 2007.

<span class="mw-page-title-main">AmigaOS</span> Operating system for Amiga computers

AmigaOS is a family of proprietary native operating systems of the Amiga and AmigaOne personal computers. It was developed first by Commodore International and introduced with the launch of the first Amiga, the Amiga 1000, in 1985. Early versions of AmigaOS required the Motorola 68000 series of 16-bit and 32-bit microprocessors. Later versions were developed by Haage & Partner and then Hyperion Entertainment. A PowerPC microprocessor is required for the most recent release, AmigaOS 4.

OpenWrt is an open-source project for embedded operating systems based on Linux, primarily used on embedded devices to route network traffic. The main components are Linux, util-linux, musl, and BusyBox. All components have been optimized to be small enough to fit into the limited storage and memory available in home routers.

References

  1. "Jaroslav Kysela - Perex soft".
  2. Alsa Team, alsa-project.org, 2008-09-29, retrieved 2012-01-08
  3. "Main Page News - AlsaProject". 10 June 2024. Retrieved 11 June 2024.
  4. "ALSA", Analysis Summary, Ohloh, archived from the original on 2013-12-20, retrieved 2012-01-08
  5. 1 2 "Introduction". alsa-project.org. Retrieved 2012-01-08.
  6. Linux 2.5.5 release notes , retrieved 2012-01-08
  7. OSS Emulation, archived from the original on 2012-06-05, retrieved 2012-07-07
  8. "Alsa-project/Alsa-tools". GitHub . 3 April 2022.
  9. "Alsa-tools - ALSA wiki". alsa.opensrc.org. Archived from the original on 18 March 2008. Retrieved 12 January 2022.
  10. "ALSA User Info - AlsaProject".
  11. "Alsa-utils". GitHub . 4 May 2022.
  12. "Category:Alsa-utils - ALSA wiki". alsa.opensrc.org. Archived from the original on 18 March 2008. Retrieved 12 January 2022.
  13. 1 2 "How to Use ALSA Utilities to Manage Linux Audio from the Terminal". 14 May 2018.
  14. 1 2 "AlsaMixers - ALSA wiki". alsa.opensrc.org. Archived from the original on 4 April 2008. Retrieved 12 January 2022.
  15. 1 2 3 boer, maarten de. "maarten's homepage". iua.upf.es. Archived from the original on 2006-09-04. Retrieved 18 July 2021. this page will contain a list of my projects, but i need to clean up some things first. for now, use the following links, or browse the ftp: tapiir, alsamixergui, aconnectgui, polarbear
  16. Boer, Maarten de. "AlsaMixerGui". Music Technology Group. Barcelona: Universitat Pompeu Fabra. Archived from the original on 2009-02-05. Retrieved 18 July 2021. alsamixergui is a FLTK based frontend for alsamixer. It is written directly on top of the alsamixer source, leaving the original source intact, only adding a couple of ifdefs, and some calls to the gui part, so it provides exactly the same functionality, but with a graphical user interface. (Researcher, 1999-2010)
  17. Tranter, Jeff (October 2004), "Introduction to Sound Programming with ALSA", Linux Journal, retrieved 2012-01-08
  18. Phillips, Dave (June 2005), "A User's Guide to ALSA", Linux Journal, archived from the original on 2012-01-09, retrieved 2012-01-08
  19. Alsa C library Doxygen documentation, October 2007, retrieved 2012-01-08
  20. "ALSA project - the C library reference: Sequencer interface". www.alsa-project.org. Retrieved 2019-04-30.
  21. ALSA SoC Layer, kernel.org, 2017-07-13
  22. "Tips And Tricks - Open Sound System". ossnext.trueinstruments.com.
  23. "Audio Architecture (QNX 6.4.1)". www.qnx.com.
  24. "ALSA and libasound.so". www.qnx.com.
Various layers within Linux, also showing separation between the userland and kernel space
User modeUser applications bash, LibreOffice, GIMP, Blender, 0 A.D., Mozilla Firefox, ...
System components init daemon :
OpenRC, runit, systemd...
System daemons :
polkitd, smbd, sshd, udevd...
Window manager :
X11, Wayland, SurfaceFlinger (Android)
Graphics:
Mesa , AMD Catalyst, ...
Other libraries:
GTK, Qt, EFL, SDL, SFML, FLTK, GNUstep, ...
C standard library fopen , execv , malloc , memcpy , localtime , pthread_create ... (up to 2000 subroutines)
glibc aims to be fast, musl aims to be lightweight, uClibc targets embedded systems, bionic was written for Android, etc. All aim to be POSIX/SUS-compatible.
Kernel mode Linux kernel stat , splice , dup , read , open , ioctl , write , mmap , close , exit , etc. (about 380 system calls)
The Linux kernel System Call Interface (SCI), aims to be POSIX/SUS-compatible [1]
Process scheduling subsystem IPC subsystem Memory management subsystem Virtual files subsystemNetworking subsystem
Other components: ALSA, DRI, evdev, klibc, LVM, device mapper, Linux Network Scheduler, Netfilter
Linux Security Modules: SELinux , TOMOYO , AppArmor , Smack
Hardware (CPU, main memory, data storage devices, etc.)
  1. "Admin Guide README". Kernel.org git repositories.