Beginners Guide for Better Audio Quality in Linux

Veda Swaroop
7 min readSep 22, 2020
Audio in Linux

Edit: Latest developments happen in the Linux world quickly. So there is a new audio server called “Pipewire” which has the potential to replace Pulseaudio and Jack audio servers. Pipe wire is great. I don’t have all the details but for anyone interested, check the below links.

PipeWire

PipeWire — ArchWiki (archlinux.org)

Introduction:

Audio quality in any Linux distribution, when compared to Windows or Mac OS is bad…but why…? Read the below paragraph to know.

The problem was the audio drivers. The audio chip manufacturers (for ex: Realtek) develop drivers for the Windows operating system. Apple creates its hardware and software, so there is no question of driver problem here. But in the case of Linux, the open-source community develops drivers. The problem here is, that developers don’t know the correct specifications of the audio hardware (The audio chip manufacturer won't provide these details to the open source community). The challenge for the developers here is, that the audio driver should work for most hardware. By most hardware I mean, the same audio chip can be used by different manufacturers in different products. For ex: Let’s just say Realtek has some audio chip, the same audio chip can be used in different laptops and desktops with different features. For the same chip, features like multi-channel HD audio with more codec support for high-end desktops and power-efficient HD audio with noise cancelling feature for internal microphone in laptops. So the developers build a driver(generic driver) that just works. That is why the audio quality in Linux is bad.

Below is a very good article that gives a clear explanation of how Linux and Windows handle audio differently.

Why there is a difference in audio quality between Windows and Linux…? What additional audio features does Windows OS have?

After wondering and not knowing why audio quality in Windows is much better than in Linux. I found out that the default audio driver in Windows OS has a built-in real-time equalizer and many other audio features such as bass boost, loudness equalization.., etc. Check the below official Microsoft document on the available audio effects in Windows 10. The audio driver developers have the choice of utilizing these OS-provided audio effects or implementing their custom audio effects.

Audio Signal Processing Modes — Windows drivers | Microsoft Docs

On top of this, audio hardware vendors such as RealTek provide proper drivers for the hardware. So that is why audio on Windows is better.

In Linux, there is no magical equalizer and other audio enhancements installed by default. There is a PulseAudio equalizer, but it needs some tuning and tweaking oneself for their hardware. The second downside is, that hardware vendors, don’t provide audio drivers for Linux. Hence, the a difference in audio quality compared to Windows or Mac OS.

Keeping this in mind, I thought of an easy guide for beginners to get the best output from their audio hardware.

The Guide:

This guide provides a simple and easy way to get better audio quality in any Linux distro that is using PulseAudio as its audio server. Follow the below 2 steps.

Should change the default settings in the pulse-audio config file. This file is generally found in /etc/pulse/daemon.conf. Before changing any settings, keep a backup of the daemon.conf file in any other location.

Note: In the daemon.conf file, all the default settings are commented using “#(Hash) or ;(semi-colon)”. To change a setting, just copy-paste the default setting to the next line, un-comment the setting, and change it.

1. Change the resample method: By default, in most distro’s resample method is speex-float-1. Here, the range is from 1(Low) to 10(Best). The higher the value, the better the audio quality and the demand for high CPU usage. This also depends on the CPU. To know the available resample methods supported by a CPU, run the following command in a terminal.

pulseaudio — dump-resample-methods

For desktop users, use the speex-float-10 or the soxr resample method. For the latest processors (less than 2–3 years old), use soxr resample methods. The soxr resample methods offer better audio quality than speex-based methods. But they are more CPU intensive than speex methods.

For laptops, speex-float resample methods are best. I recommend using speex-float-5, speex-float-6 or speex-float-7. Check the CPU usage of the PulseAudio process using htop or any system monitor. Choose the best resample method that fits perfectly between battery life and audio quality.

2. Change default sample format: Firstly, the Endianness of the CPU should be checked before changing the default sample format. This can be easily found by using the following command.

lscpu | grep ‘Byte Order'

The CPU can be either little-endian or big-endian. Remember the CPU endianness, we need this later.

First, let’s understand the audio bit depth. We have 8-bit, 16-bit, 24-bit, and 32-bit depth sample formats. Currently, 8-bit audio is rarely used(It is old). 16-bit audio is used in music streaming services and in general, many audio files use 16-bit depth. 24-bit is known as High-Res audio. FLAC and Apple’s ALAC lossless audio codecs use 24-bit audio. Some premium audio streaming services use 24-bit audio. So, if you have 24-bit FLAC, ALAC files, or any other high-quality audio files, go for 24-bit. Now, 32-bit depth is for even higher-quality audio. Some advanced codecs like HEVC (or) h265 codec and others support 32-bit depth files. The easy way to find bit depth for any audio or video file is by using vlc media player. Play the file and select Tools →Codec Information. Below is an example.

Codec Information of a file using a VLC media player

Most distros use s16le or s16be as the default sample format. Let's understand this. Here in s16le, ‘s’ means signed integer, and ‘le’ means little Endian CPU, or in the case of s16be, ‘be’ means big Endian CPU. The number 16 denotes the bit depth.

Let’s see the available audio quality options in Windows.

In Windows, 24bit, 48000 HZ is Studio Quality Audio
In Windows, 16-bit, 48000 Hz is DVD Quality Audio

Change the default sample format according to your preference (like bit depth) and CPU Endianness. Here are some examples of default-sample format.

s16le, s24le, s32le (or) s16be, s24be, s32be, float32le, float32be. {float formats should be better than signed integer formats mathematically. If you know this.}

Below is an official link for all the supported audio formats by pulseaudio. Check the link below to get some idea about audio formats.

Using the above steps as a reference, change the resample method and default-sample format to your liking in the pulseaudio daemon.conf file. In the daemon.config file, there is default-sample-rate and alternate-sample-rate which are 44100 Hz and 48000 Hz respectively.

In Windows, 48000 Hz is the default sample rate and no alternate one. But in PulseAudio, we have both. If you need 48KHz as default, set the default sample rate to 48000 Hz or leave it as is, the choice is yours. If you do change it, then what should be the alternate-sampling rate..? Leave it to 48000 Hz or change it to 44100 Hz. If you are tech-savvy and know that your audio hardware supports higher sampling rates such as 96KHz, 192KHz.. etc. Change the alternate sampling rate to your hardware-supported high sampling rate.

Check out the arch wiki page on what all these settings do, using the link below.

After these changes, save the daemon.conf file and reboot the system. Play any audio file and check the quality. These changes will improve the overall audio quality in Linux. But when compared to Windows or Mac OS, we are missing a few things.

The first thing is an equalizer, we have pulseaudio equalizer (it is hard to learn and tune correctly) and pulse effects(has built-in presets for equalizer) which now changed their name to easyeffects (to support pipewire). The pulse effects are not just an equalizer, it is a fully-featured audio effects suite. Check out the pulse effects/easy effects GitHub page using the link below to learn more about it.

The pulse effects have a built-in equalizer with presets like perfect equalizer, bass-boosted, bass-heavy, and so on. This application solves the equalizer part. The only other thing missing is loudness equalization.

Loudness-equalization can be achieved. I think there is a GitHub repo regarding that. Alternatively, by learning how to play with pulse effects, loudness equalization can be achieved.

I hope this guide helps to solve the audio problem in Linux. If you find it useful or have some suggestions or any other improvements please share your thoughts and comments below.

--

--

Veda Swaroop

I love Science, Technology, Linux and Computers in general. A.I, Machine Learning, Deep Learning Enthusiast.