Advanced Linux Sound Architecture (ALSA)

Vicente González Ruiz

November 4, 2014

Contents

1 What is ALSA?
2 Installation
3 Recognized audio hardware
4 Playback devices
5 PCM DAC (playback) device names
6 Capture devices
7 PCM ADC (capture) device names
8 Cards, devices, and subdevices
9 (Very basic) Configuration
10 Permissions
11 alsa: the deamon handler
12 amixer: a command-line mixer
13 alsamixer: a ncursed-based mixer
14 speacker-test: a command-line pink noise generator
15 Sampling parameters
16 Capture limits
17 Capture and playback PCM data (basic example)

1 What is ALSA?

2 Installation

3 Recognized audio hardware

$ cat /proc/asound/card*/id

4 Playback devices

$ aplay -l  
**** List of PLAYBACK Hardware Devices ****  
card 0: NVidia [HDA NVidia], device 0: ALC889A Analog [ALC889A Analog]  
  Subdevices: 0/1  
  Subdevice #0: subdevice #0  
card 0: NVidia [HDA NVidia], device 1: ALC889A Digital [ALC889A Digital]  
  Subdevices: 1/1  
  Subdevice #0: subdevice #0  
 
# In this example, there is a sound card named "Nvidia"  
# which has two playback devices "ALC889A Analog" and "ALC889A Digital".  
# You can extract the sound card names by using:  
 
$ aplay -l | awk -F \: ’/,/{print $2}’ | awk ’{print $1}’ | uniq

5 PCM DAC (playback) device names

$ aplay -L  
null  
    Discard all samples (playback) or generate zero samples (capture)  
pulse  
    PulseAudio Sound Server  
equal  
plugequal  
default  
    Playback/recording through the PulseAudio sound server  
sysdefault:CARD=NVidia  
    HDA NVidia, ALC889A Analog  
    Default Audio Device  
front:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Front speakers  
surround40:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    4.0 Surround output to Front and Rear speakers  
surround41:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    4.1 Surround output to Front, Rear and Subwoofer speakers  
surround50:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    5.0 Surround output to Front, Center and Rear speakers  
surround51:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers  
surround71:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers  
iec958:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Digital  
    IEC958 (S/PDIF) Digital Audio Output  
dmix:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Direct sample mixing device  
dmix:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Direct sample mixing device  
dsnoop:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Direct sample snooping device  
dsnoop:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Direct sample snooping device  
hw:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Direct hardware device without any conversions  
hw:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Direct hardware device without any conversions  
plughw:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Hardware device with all software conversions  
plughw:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Hardware device with all software conversions

6 Capture devices

$ arecord -l  
**** List of CAPTURE Hardware Devices ****  
card 0: NVidia [HDA NVidia], device 0: ALC889A Analog [ALC889A Analog] # Line in  
  Subdevices: 1/1  
  Subdevice #0: subdevice #0  
card 0: NVidia [HDA NVidia], device 1: ALC889A Digital [ALC889A Digital] # SPDIF  
  Subdevices: 1/1  
  Subdevice #0: subdevice #0  
card 0: NVidia [HDA NVidia], device 2: ALC889A Alt Analog [ALC889A Alt Analog] # Mic  
  Subdevices: 2/2  
  Subdevice #0: subdevice #0  
  Subdevice #1: subdevice #1

7 PCM ADC (capture) device names

$ arecord -L  
null  
    Discard all samples (playback) or generate zero samples (capture)  
pulse  
    PulseAudio Sound Server  
equal  
plugequal  
default  
    Playback/recording through the PulseAudio sound server  
sysdefault:CARD=NVidia  
    HDA NVidia, ALC889A Analog  
    Default Audio Device  
front:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Front speakers  
surround40:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    4.0 Surround output to Front and Rear speakers  
surround41:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    4.1 Surround output to Front, Rear and Subwoofer speakers  
surround50:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    5.0 Surround output to Front, Center and Rear speakers  
surround51:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers  
surround71:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers  
iec958:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Digital  
    IEC958 (S/PDIF) Digital Audio Output  
dmix:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Direct sample mixing device  
dmix:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Direct sample mixing device  
dmix:CARD=NVidia,DEV=2  
    HDA NVidia, ALC889A Alt Analog  
    Direct sample mixing device  
dsnoop:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Direct sample snooping device  
dsnoop:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Direct sample snooping device  
dsnoop:CARD=NVidia,DEV=2  
    HDA NVidia, ALC889A Alt Analog  
    Direct sample snooping device  
hw:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Direct hardware device without any conversions  
hw:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Direct hardware device without any conversions  
hw:CARD=NVidia,DEV=2  
    HDA NVidia, ALC889A Alt Analog  
    Direct hardware device without any conversions  
plughw:CARD=NVidia,DEV=0  
    HDA NVidia, ALC889A Analog  
    Hardware device with all software conversions  
plughw:CARD=NVidia,DEV=1  
    HDA NVidia, ALC889A Digital  
    Hardware device with all software conversions  
plughw:CARD=NVidia,DEV=2  
    HDA NVidia, ALC889A Alt Analog  
    Hardware device with all software conversions

8 Cards, devices, and subdevices

9 (Very basic) Configuration

10 Permissions

11 alsa: the deamon handler

12 amixer: a command-line mixer

13 alsamixer: a ncursed-based mixer

PIC

14 speacker-test: a command-line pink noise generator

$ speaker-test -c 2                  # Analog (Headphones) stereo  
$ speaker-test -Dplug:spdif -c2      # Didital (SPDIF) stereo  
$ speaker-test -surround71:HDMI -c 8 # 7.1

15 Sampling parameters

  1. Sample rate: number of audio samples per second.
  2. Sample format: signed, unsigned, bit/sample, etc.
  3. Number of channels and data layout: refers to the number of channels and the samples interleaving.
  4. Buffer size: This determines how large the hardware buffer is. It is related with the latency.

16 Capture limits

17 Capture and playback PCM data (basic example)

$ arecord -f cd | aplay -f cd  
Recording WAVE ’stdin’ : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo  
Playing WAVE ’stdin’ : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo  
underrun!!! (at least 209,120 ms long)  
^CAborted by signal Interrupt...  
aplay: pcm_write:1939: write error: Interrupted system call  
Aborted by signal Interrupt...