Configuring Linux for the Most Optimal Audio Quality
ALSA⌗
ALSA has a default volume level that does not fully utilize your card’s volume range. In the /usr/share/alsa/init/default
file you may find:
nt
ENV{ppercent}:="75%"
ENV{cpercent}:="75%"
ENV{pvolume}:="-20dB"
ENV{cvolume}:="12dB"
This is a safe default value that ALSA uses by default, but it’s not optimal and you will find that your volume is lower than expected. If you want to use 100% of the volume range (and thus preamps) of your card, you should set these values to 0db and 100%.
If this works, next time you open alsamixer
your levels should be at maximum. This is not an issue since this handles the digital domain, where anything that isn’t using the full bit range before being converted to analogic is not optimal.
I’ve found that if you are using Pipewire this is not necessary.
Pulseaudio⌗
You can set pulseaudio to use a different sample rate if you have content (or record) with higher bit rates in /etc/pulse/daemon.conf
:
# Use 24bit sample rate if your card supports
default-sample-format = s24le
# or 32bit if your card supports it
default-sample-format = s32le
Same can be done with sample rates:
# Check your card's manual for sample rates. You can also check /proc/asound
default-sample-rate = 48000
alternate-sample-rate = 44100
Setting multiple sample rates allows Pulseaudio to use a rate that is equivalent to the content being reproduced, avoiding resampling where possible. Resampling does alter the original content, so you want to avoid if you can. However, if you do need to resample, you can choose to use a better resampler than the default:
# Might be overkill for most applications
resample-method = soxr-vhq
avoid-resampling = true
As a bonus, you can lower the latency and improve the responsiveness of Pulseaudio with the following:
high-priority = yes
nice-level = -15
# Fix the latency in 16ms (useful if you can't use tsched)
default-fragments = 2
default-fragment-size-msec = 8
Pipewire⌗
Pipewire has better defaults than Pulseaudio. You shouldn’t need to change anything to get good sound, but if you still want to ensure you are using the most overkill settings you can increase the resampling quality for pipewire clients in /etc/pipewire/client.conf.d/client.conf
, /etc/pipewire/client-rt.conf.d/client-rt.conf
and /etc/pipewire/pipewire-pulse.conf.d/pipewire-pulse.conf
:
stream.properties = {
resample.quality = 10
}
You should not need to change rates with Pipewire, but if you want to set your preferred rates you can use /etc/pipewire/pipewire.conf.d/pipewire.conf
and set:
context.properties = {
default.clock.allowed-rates = [ 44100 48000 96000 192000 ]
}
This is all audiophile snake oil⌗
You can argue that for most of the cases this will not make an audible change. The same can be said for lossless versus lossful formats, most of the people most of the time can’t hear the difference between FLAC and 320kbps MP3, for example.
I agree with that in some terms, however, lossy compression and lossy resampling can happen multiple times throughout the signal chain. The signal gets degraded in each lossy step, and in the end you can have an audible impact from all the small losses in the signal chain.
Removing or reducing these losses along the way, including your source material, is important for audio quality even if you have a lossful step in your signal chain (like wireless bluetooth headphones), as all these losses are amounted to the end result.
But still, at the end of the day, the best tweak to your audio system is yourself to sit back and get lost in the music, and forget of all the technicalities behind it.