audio - bunnyamin/bunnix GitHub Wiki

Device

Command Example
List all soundcards $ cat /proc/asound/cards
List platback hardware devices $ aplay --list-devices
List programs using sound drivers $ fuser -v /dev/snd/*
List sound PCI devices $ lspci | grep -i audio
List soundcard codecs $ cat /proc/asound/<CARD>/codec* | grep Codec
Loaded sound drivers $ /sbin/lsmod | grep snd

ALSA (Advanced Linux Sound Architecture)

Command Example
Restart alsactl restore

Configuration

File Comment
/etc/modprobe.d/alsa-base.conf
/etc/asound.conf Generic user configuration.
~/.asoundrc Specefic user configuration.

Amplify

Amplify the sound in order to increase the maximal sound level if it is perceived as too low.

Case (2021-12-24) Arch Linux, device (0) HDA Intel PCH, codec Realtek ALC887-VD

Added the following code to ~/.asoundrc and closed Alsa mixer and any program that use audio, whereafter restarting Alsa and then the Alsa mixer the new "pre-amp" controller was available. That is, no reboot was required.

pcm.!default {
  type plug
  slave.pcm "softvol"
}
pcm.softvol {
  type softvol
  slave {
    pcm "dmix"
  }
  control {
    name "Pre-Amp"
    card 0
  }
  min_dB -5.0
  max_dB 20.0
  resolution 6
}

Debug

Verfiy playback from device.

  • # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
  • aplay -D plughw:<CARD>,<DEVICE> /usr/share/sounds/alsa/Noise.wav

Pulseaudio

Configuration

  • ~/.config/pulse/
  • /etc/pulse/

Remote

https://archlinux.org/packages/extra/x86_64/socat/

  • Ensure that the RTP module is installed for Pulseaudio on server and client.
  • On server, copy /etc/pulse/default.pa to ~/.config/pulse/ from where to stream audio.
    • Add load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/16 in ~/.config/pulse/default.pa.
    • Use auth-anonymous=true to allow access from everywhere.
    • If neither authorization method is assigned then pulseaudio defaults to the use of ~/.config/pulse/cookie, which must be the same on clients and server.
    • Pulseaudio is automatically started through the pulseaudio.socket, control using systemctl --user status pulseaudio.
    • Verify that Pulseaudio is listining to port.
    • If server inside qemu: forward port <HOST PORT> to <VM PORT>
    • If behind a firewall, open <HOST PORT>.
  • On client, copy /etc/pulse/client.conf to ~/.config/pulse/ from where to connect to server.
    • Uncomment and assign server IP or hostname default-server = <SERVER:PORT>192.168.2.101:4999.
    • Query connection to server with with pactl -s <SERVER IP>:<SERVER PORT> info.

Debug

  • pacmd list-cards
  • pacmd list-sinks

Error, problem, troubleshoot

Error Cause Remedy
Distortion, crackling reverb echo The sound driver cannot handle the PulseAudio timer-based scheduling, which allows for better latency management and reduced CPU usage. Disable timer-based scheduling and enable the classic interrupt-driven approach. In /etc/pulse/default.pa, add tsched=0 to the line where load-module module-udev-detect, that is, load-module module-udev-detect tsched=0 (see answer by heftig 2011-04-19 10:57:50 to question concerning "PULSEAUDIO Crackling / Distortion").
No sound Unknown, "glitch"? Go trough all relevant sound channels and mute, un-mute them.
⚠️ **GitHub.com Fallback** ⚠️