Home Theatre Audio Experience on Linux Using Headphones

Utilizing Pipewire for 5.1 or 7.1 virtual surround sound
linux
htpc
Author

Nishan Mann

Published

May 16, 2025

Introduction

When it comes to videos, I have two pet peeves: viewing distance is too far to fully appreciate the resolution and a subpar audio setup. Perhaps influenced by marketing tactics, generally there is more emphasis on screen size and resolution than audio. For those that realize the importance of audio, unfortunately the same tactics guide them towards soundbars or multi-speaker setups which can cost hundreds or thousands of dollars. In this post, I demonstrate how to achieve a home theatre like audio experience using decent headphones or in-ear monitors (IEMs) in Linux.

A video file can contain one or more audio formats, the best of which is selected depending on your audio setup. There are 2 categories of audio formats: channel-based audio or object-based audio. Channel based audio represents sound as emanating from a discrete number channels or speakers. For example, 1 channel aka Mono or 1.0, 2 channels aka Stereo or 2.0 (the most common), 2+1 subwoofer aka 2.1, 5+1 subwoofer aka 5.1 surround or 7+1 subwoofer aka 7.1 surround. Some proprietary encoders for channel based surround sound are Dolby Digital, Dolby TrueHD, DTS-HD etc. Object based audio is the newer paradigm that represents sound as a collection of objects moving in 3D space that adapts to the user’s speaker setup. Some proprietary encoders are Dolby Atmos, DTS:X and Eclipsa Audio. For this post, we will focus on creating a virtual surround setup for channel-based audio because its widely available in most video files and object based audio formats are backwards compatible with channel based audio formats. The limitation is that the surround sound effect will be limited to a 2D plane instead of 3D, i.e. no sounds coming from above or below you.

We hear sound through our ears so its fair to ask, why do I need a multi speaker setup to experience surround sound, can’t I just use my headphones? Turns out you can! Thanks to the concept of a head-related transfer function (HRTF). The HRTF is a mathematical transformation applied to 5.1/7.1 channel audio to transform it down to 2 channels that contain all the relevant information (amplitude and phase) to reproduce a 5.1/7.1 speaker setup. This is visually illustrated in Figure 1. The HRTF is either determined from lab measurements using microphones placed inside a dummy head’s ear canals or extracted from existing softwares offering HRTF transformations.

Figure 1: A schematic illustration of HRTF generated courtesy of Microsoft Copilot.

Setup

I have gone through and experimented with different HRTFs and narrowed down the ones that work for me. Hopefully they also work for you. Assuming your Linux distribution is using pipewire as the audio server, here are the steps to enable 5.1/7.1 virtual surround in Linux:

  1. mkdir ~/.config/pipewire/filter-chain.conf.d/; cd ~/.config/pipewire/filter-chain.conf.d/ Create the directory that stores the config files.
  2. curl -o ~/.config/pipewire/filter-chain.conf.d/sink-virtual-surround-5.1-kemar.conf https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/src/daemon/filter-chain/sink-virtual-surround-5.1-kemar.conf?inline=false. This creates a file called sink-virtual-surround-5.1-kemar.conf in the directory from step 1.
    1. Download the HRTF for 5.1 surround sound called hrir-kemar.wav 1. Assuming the downloaded file path is /path/to/hrir-kemar.wav, open the sink-virtual-surround-5.1-kemar.conf file in your text editor and replace lines filename = "hrir_kemar/hrir-kemar.wav" with filename = "/path/to/hrir-kemar.wav".
  3. Repeat step 2. for 7.1 surround sound. curl -o ~/.config/pipewire/filter-chain.conf.d/sink-virtual-surround-7.1-hesuvi.conf https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/src/daemon/filter-chain/sink-virtual-surround-7.1-hesuvi.conf?inline=false.
    1. The HRTF for 7.1 surround sound that I use is oal_dflt.wav.
    2. In sink-virtual-surround-7.1-hesuvi.conf replace filename = "hrir_hesuvi/hrir.wav" with filename = "/path/to/oal_dflt.wav"

Now run pipewire -c filter-chain.conf to create two new audio sinks. They will be named Virtual 5.1 Surround Sound Sink and Virtual 7.1 Surround Sound Sink respectively (as indicated by the node.description, media.name in the conf files). You can test your sinks using your desktop environment’s sound management application (don’t forget to plug in your 🎧). On my GNOME desktop, this looks as follows:

Audio Demos

Here are some sample video files to test your setup 2. I do not know how to enable switching audio tracks in videos embedded using HTML5, so I provide the same videos but vary the number of audio channels below.

2.0 Audio

Use your default sound sink for this.

5.1 Audio

Use the Virtual 5.1 Surround Sound Sink for audio playback and compare your experience with 2.0 audio. Hint: subtlety is key, closing your eyes might help you to spot the difference.

7.1 Audio

Use the Virtual 7.1 Surround Sound Sink for audio playback and compare your experience.

Conclusion

Enjoy your home theatre audio experience in Linux for a fraction of the cost!

References

  • For more media samples, visit Demolandia.
  • If you don’t like my HRTFs, feel free to look for alternatives in the HRTF database.
  • Prompt for Figure 1. “Draw me a figure that explains the concept of a head related transfer function (HRTF). Try to show how a HRTF works to transform 5.1 or 7.1 audio down to 2 channels that emulates the surround sound effect”

Footnotes

  1. Technically this file contains the head related impulse response (HRIR) function which is the time domain representation of the HRTF.↩︎

  2. Although the video files mention Dolby Atmos, you will not be able to hear elevation in the soundtrack.↩︎