Skip to content

Commit f266b33

Browse files
committed
docs: improve explaination with more context on ALSA and images
1 parent 8881b4a commit f266b33

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed
125 KB
Loading
380 KB
Loading

ubuntu-desktop/explanation/audio-on-ubuntu.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
1+
# How does Audio on Ubuntu Desktop work
2+
13
This page explains how audio works on Ubuntu desktop from the hardware layer to the application layer.
24

35
## The hardware layer
46

57
When you use applications that play or record audio, they get the audio input from hardware like microphones and return audio output using speakers.
68

7-
This is made possible using sound cards, which translate digital signals into the analog sound waves you hear through speakers or headphones, and vice versa for microphones.
9+
This is made possible through sound cards, which translate digital signals into the analog sound waves you hear through speakers or headphones, and vice versa for microphones. This process involves DAC (Digital-to-Analog Conversion) for output and ADC (Analog-to-Digital Conversion) for input.
10+
11+
Linux uses audio device drivers to interact with the sound cards. These device drivers require a kernel-level interface to transfer/receive the digital audio stream to/from applications.
812

9-
Once the hardware is in place, Linux uses audio kernel drivers to interact with the sound cards. Early Linux distributions (pre-2.6 kernel) used OSS (Open Sound System), which was the first standardized audio kernel driver that allowed programs to play and record audio. However, due to its limitations and because it was partially “closed source,” it was replaced by ALSA.
13+
Early Linux distributions (pre-2.6 kernel) used OSS (Open Sound System), the first standardized kernel-level interface that allowed applications to play and record audio. However, due to its limitations and because it was partially proprietary software, OSS was replaced by ALSA.
1014

1115
## Advanced Linux Sound Architecture (ALSA)
1216

13-
ALSA was created as a replacement for OSS to address its limitations as the default audio kernel driver for Linux machines. It’s an open-source driver that provides audio and MIDI (Musical Instrument Digital Interface**)** functionality.
17+
ALSA was created as a replacement for OSS to address its limitations as the default audio kernel-level interface for Linux machines. It’s an open-source driver that provides audio and MIDI (Musical Instrument Digital Interface**)** functionality.
18+
19+
ALSA interacts with audio hardware primarily through specialized device drivers provided by the Linux kernel. Its role is to abstract hardware complexity to make it easier for user-space applications to communicate with audio hardware. To achieve this, it includes specific kernel modules for different audio hardware. Upon booting, these modules automatically detect audio devices connected to the system, such as professional soundcards, USB audio devices, and HDMI/DisplayPort audio output.
1420

15-
It featured efficient support for all types of audio interfaces, from consumer sound cards to professional multichannel audio interfaces, and a user-space library (`alsa-lib`) to simplify application programming—things OSS didn't have. It also supported programs that expected the older Open Sound System (OSS) API for backward compatibility purposes.
21+
Then, it creates special device files under `/dev/snd/` that represent audio devices. For example, `/dev/snd/pcm*` (for playback/capture), `/dev/snd/control*` (hardware mixer controls), and `/dev/snd/midi*` (MIDI interfaces).
1622

17-
However, ALSA has some limitations. Only one application could play audio simultaneously unless extra software (like Dmix) were configured. Other limitations of ALSA include poor support for hotplug devices (like USB headphones), and a lack of a user-friendly GUI and per-application volume controls.
23+
When an application wants to play audio, it sends the audio data through the ALSA API (`libasound`), it passes through ALSA libraries and plugins, is processed by kernel drivers, moved via DMA (Direct Memory Access) to the hardware, converted into an analog signal by the DAC (Digital to Analog Coverter), and ultimately reaches your speakers or headphones.
1824

19-
To address ALSA’s limitation, sound servers were introduced to Linux machines.
25+
![ALSA only flow on Ubuntu](../assets/explanation/audio-on-ubuntu/alsa-flow.jpg)
26+
27+
ALSA featured efficient support for all types of audio interfaces, from consumer sound cards to professional multichannel audio interfaces, and a user-space library (`alsa-lib`) to simplify application programming—things OSS didn't have. It also supported programs that expected the older Open Sound System (OSS) API for backward compatibility.
28+
29+
However, ALSA had a major limitation: only one application could play audio simultaneously unless extra software (like Dmix) were configured. Additionally, it had poor support for hotplug devices (like USB headphones), and a lack of a user-friendly GUI and per-application volume controls. To address ALSA’s limitation, sound servers were introduced to Linux machines.
2030

2131
## Sound servers
2232

23-
A sound server is an intermediary between an application (Firefox, VLC) and ALSA.
33+
A sound server is an intermediary between an application (Firefox, VLC) and ALSA that manages audio streams from multiple applications, mixes them in real time, and forwards the mixed output to ALSA, which then communicates with the hardware. Ubuntu has seen a few sound servers, including PulseAudio, JACK, and Pipewire.
2434

2535
### PulseAudio
2636

@@ -46,9 +56,11 @@ With PipeWire, applications that previously needed bridges to work together can
4656

4757
On Ubuntu desktop (22.10), when an application wants to play or record audio, it interacts directly with Pipewire. If the application initially expected a PulseAudio or a JACK interface, Pipewire would provide such using the appropriate compatibility layer. Pipewire, in turn, communicates with ALSA to send or receive audio. ALSA then handles the low-level interaction with the sound card.
4858

59+
![How audio works on ubuntu](../assets/explanation/audio-on-ubuntu/alsa-flow.jpg)
60+
4961
Some applications can also talk to ALSA directly; for example, `aplay` and `arecord` (command-line tools) use ALSA directly. Some music production apps (like Ardour or Reaper) can talk directly to ALSA *or* JACK to reduce latency.
5062

51-
## Resources
63+
## Additional Resources
5264

5365
- [The ALSA Project](https://www.alsa-project.org/wiki/Main_Page)
5466
- [Pipewire](https://pipewire.org/)

0 commit comments

Comments
 (0)