Preface

Know Your System, Focusing on Audio

I love listening to music. A linux without sound is killing me. After all this linux years, I am still curious about this sound thing.

Altough I’m using openSUSE. This article can be a reference to other linux as well.

I mostly pour my daily linux troubleshooting in a blog, so I can find the solution easily, if I have similar issue another day.

Table of Content


1: The Operating System Part

Before getting into detail on how the sound works perfectly or no sound at all, first we should examine the system wide setting, that is provided by the operating system.

The Hardware Information

I always use lspci as my starting point. Well, I’m not an expert. I could be wrong. Other people mught have different starting point.

% /sbin/lspci | grep -i audio
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 01)

audio: lspci grep audio

Now that we have this 00:1b.0, we can have a more verbose information.

% /sbin/lspci -vnn -s 00:1b.0
00:1b.0 Audio device [0403]: Intel Corporation NM10/ICH7 Family High Definition Audio Controller [8086:27d8] (rev 01)
    Subsystem: Gigabyte Technology Co., Ltd GA-D525TUD (Realtek ALC887) [1458:a002]
    Flags: bus master, fast devsel, latency 0, IRQ 24
    Memory at fdff8000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: <access denied>
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

It is crazy. This command know that I have realtek ALC887.

Note with this suspicious access denied message, my sound card still works perfectly.

    Capabilities: <access denied>

audio: lspci verbose

Now, how about lsmod.

% /bin/lsmod | grep -i intel
snd_hda_intel          45056  3
snd_hda_codec         147456  3 snd_hda_intel,snd_hda_codec_generic,snd_hda_codec_realtek
snd_hda_core           90112  4 snd_hda_intel,snd_hda_codec,snd_hda_codec_generic,snd_hda_codec_realtek
snd_pcm               147456  3 snd_hda_intel,snd_hda_codec,snd_hda_core
snd                    98304  13 snd_hda_intel,snd_hwdep,snd_hda_codec,snd_timer,snd_hda_codec_generic,snd_hda_codec_realtek,snd_pcm

audio: lsmod grep intel


Boot Messages

Simply issue dmesg (display message) command. And filter it with grep looking for text contining snd.

% dmesg | grep -i snd
[   20.972887] snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC887-VD: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:line
[   20.975968] snd_hda_codec_realtek hdaudioC0D2:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   20.979016] snd_hda_codec_realtek hdaudioC0D2:    hp_outs=1 (0x1b/0x0/0x0/0x0/0x0)
[   20.982165] snd_hda_codec_realtek hdaudioC0D2:    mono: mono_out=0x0
[   20.985222] snd_hda_codec_realtek hdaudioC0D2:    inputs:
[   20.988224] snd_hda_codec_realtek hdaudioC0D2:      Rear Mic=0x18
[   20.991264] snd_hda_codec_realtek hdaudioC0D2:      Front Mic=0x19
[   20.994229] snd_hda_codec_realtek hdaudioC0D2:      Line=0x1a
[   20.997186] snd_hda_codec_realtek hdaudioC0D2:      CD=0x1c

audio: dmesg grep snd

Or you can issue a more specific filter. But this is useless.

% dmesg | grep -i alc887
[   20.972887] snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC887-VD: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:line

audio: dmesg grep alc

I mean, please be careful on filtering. You might lose important message that you are searching for.


Device

Device is listed on /dev/snd.

%  ls -l /dev/snd
total 0
drwxr-xr-x  2 root root       60 Jun 22 20:37 by-path
crw-rw----+ 1 root audio 116,  2 Jun 22 20:37 controlC0
crw-rw----+ 1 root audio 116,  6 Jun 22 20:37 hwC0D2
crw-rw----+ 1 root audio 116,  4 Jun 22 20:38 pcmC0D0c
crw-rw----+ 1 root audio 116,  3 Jun 22 21:11 pcmC0D0p
crw-rw----+ 1 root audio 116,  5 Jun 22 20:37 pcmC0D2c
crw-rw----+ 1 root audio 116,  1 Jun 22 20:37 seq
crw-rw----+ 1 root audio 116, 33 Jun 22 20:37 timer

audio: /dev/snd


Process

The /dev/snd directory is not the only place to go. How about /proc/asound ?

% ls -l /proc/asound/
total 0
dr-xr-xr-x 5 root root 0 Jun 22 22:07 card0
-r--r--r-- 1 root root 0 Jun 22 22:07 cards
-r--r--r-- 1 root root 0 Jun 22 22:07 devices
-r--r--r-- 1 root root 0 Jun 22 22:07 hwdep
lrwxrwxrwx 1 root root 5 Jun 22 22:07 Intel -> card0
-r--r--r-- 1 root root 0 Jun 22 22:07 modules
dr-xr-xr-x 2 root root 0 Jun 22 22:07 oss
-r--r--r-- 1 root root 0 Jun 22 22:07 pcm
dr-xr-xr-x 2 root root 0 Jun 22 22:07 seq
-r--r--r-- 1 root root 0 Jun 22 22:07 timers
-r--r--r-- 1 root root 0 Jun 22 22:07 version

audio: /proc/asound

We can use this later to get the codec.

% cat /proc/asound/card0/codec\#2 | grep -i codec
Codec: Realtek ALC887-VD

audio: codec /proc

% cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k4.14.9-1-default.

audio: /proc/asound/version


User and Group

One said that most the important aspect is the permission.

% cat /etc/group | grep audio
audio:x:496:pulse,mpd

audio: user group


2: The Audio Part

Now it is depend on the driver and audio handler in your system. Mine could be difference with yours.

Pulseaudio

My openSUSE as pulseaudio set by default.

% pulseaudio --check
% pulseaudio --kill
% pulseaudio --start

audio: pulseaudio

aplay: List Devices

You must have been heard about this aplay tool.

Consider issue aplay -l command. However, be aware of lowercase argument.

% aplay --list-devices
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

audio: aplay list devices

Now it is time to test if the audio works.

% aplay /usr/share/sounds/alsa/test.wav
Playing WAVE '/usr/share/sounds/alsa/test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

audio: aplay test using wav file

You should hear something from your speaker by now.

aplay: List PCM

Consider issue aplay -L command. However, be aware of uppercase argument.

% aplay --list-pcm
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=Intel
    HDA Intel, ALC887-VD Analog
    Default Audio Device
front:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    Front speakers
surround21:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
    HDA Intel, ALC887-VD Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speaker

audio: aplay list pcm

PCM: Pulse Code Modulation


alsamixer

Now you can djust volume by issue alsamixer command.

% alsamixer

audio: alsamixer

And press ESC to quit.


xfce4-mixer

If you wish for GUI, you can use xfce4-mixer as well.

% xfce4-mixer &!

audio: xfce4-mixer


pavucontrol

Or more eleganly for pulseaudio, you can use pavucontrol.

% pavucontrol &!

audio: pavucontrol


3: Miscellanous

Volume Control: amixer

$ amixer -D pulse sset Master '5%+'
$ amixer -D pulse sset Master '5%-'
$ amixer set Master toggle

audio: amixer

Volume Control: pactl

pactl and pacmd.

% pactl set-sink-volume 0 +1%
% pactl set-sink-volume 0 80%

audio: pactl

Information: pactl

% pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 32
Server Protocol Version: 32
Is Local: yes
Client Index: 110
Tile Size: 65472
User Name: epsi
Host Name: andalan
Server Name: pulseaudio
Server Version: 11.1
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.pci-0000_00_1b.0.analog-stereo
Default Source: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
Cookie: d448:eedf

audio: pactl


Conclusion

That’s not all. Not at all.

There are still a lot of things to explore with audio sound. But I have only limited knowledge.

Thank you for reading