Skip to content

Instantly share code, notes, and snippets.

@cbrunnkvist
Created July 26, 2025 06:17
Show Gist options
  • Save cbrunnkvist/7954ca6827f5f1fdd32d2f5564f2d595 to your computer and use it in GitHub Desktop.
Save cbrunnkvist/7954ca6827f5f1fdd32d2f5564f2d595 to your computer and use it in GitHub Desktop.
Linux ALSA software preamp config
# (I use /etc/asound.conf instead of ~/.asoundrc because I run `shairport-sync` as a system service)
pcm.analog_out { # Defines a new PCM (Pulse Code Modulation) device named "analog_out". This serves as a direct reference to your physical analog output.
type plug # Specifies that this PCM is a "plug" type, which means it can handle format conversions and routing to another PCM.
slave.pcm "hw:PCH,0" # Sets the "slave" PCM to the actual hardware device. "hw:PCH,0" refers to your sound card (PCH) and its analog output device (device 0).
}
# ---
pcm.preamp { # Defines a new PCM device named "preamp". This is your software pre-amplifier.
type softvol # Specifies that this PCM device is a software volume control.
slave { # Defines the "slave" PCM, which is the actual audio output device this softvol controls.
pcm "analog_out" # Sets the slave PCM to "analog_out", meaning audio will be routed through your direct analog output after softvol processing.
}
control { # This block defines the mixer control that will be visible in ALSA mixer applications like `alsamixer`.
name "Pre-amp" # Sets the user-friendly name of the mixer control that will appear in mixer utilities.
card 0 # Associates this mixer control with sound card 0 (your "HDA Intel PCH").
}
min_dB -50.0 # Sets the minimum volume level for the "Pre-amp" control, in decibels (dB). Allows for significant attenuation.
max_dB 20.0 # Sets the maximum volume level for the "Pre-amp" control, in decibels (dB). Allows for some amplification.
resolution 128 # Defines the number of steps (granularity) for the volume control between min_dB and max_dB. A higher number means finer control.
}
# ---
pcm.!default { # Defines the system's default PCM device. The "!" makes it override any other default setting.
type plug # Specifies that this default PCM is a "plug" type, allowing for routing.
slave.pcm "preamp" # Sets the default output to your "preamp" PCM. This means any application playing to the default ALSA device will use your software pre-amp first.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment