[HowTo] Setting up virtual surround sound for headphones

There’s a PulseAudio module which can take advantage of how headphones and your brain works to simulate surround sound without requiring a full set of speakers.

As every person hears sound slightly differently you’ll need to spend some time tweaking to find the most effective setup.

Step 1: obtain reference files

Download and extract https://stuff.salscheider-online.de/hrir_listen.tar.gz and open the demos directory. There are a number of sample files which demonstrate various recordings of a sound.

Spend some time going through these (e.g. add them to a playlist) and make a note of which one gives the best impression of a noise moving around your head in a circle (from behind, to right, to in front, to left).

Once you have found the “best” file, copy the corresponding “hrir” file from the hrirs directory somewhere easy to reach. For this tutorial, I’ll copy the file to $HOME/.local/share/hrir.wav .

If you don’t want to faff and just want a generic hrir file, download https://stuff.salscheider-online.de/hrir_kemar.tar.gz and use the single hrir file in the archive.

Step 2: obtain output name

You may have several audio outputs, but we need to know which one to send the virtual surround output to.

Run

$ pacmd list-sinks | grep -e 'name:'
	name: <alsa_output.pci-0000_06_00.1.hdmi-stereo>
	name: <alsa_output.pci-0000_08_00.3.analog-stereo>

and make a note of the output you want to use. I’ll be using the “analog stereo” output.

Step 3: Add a test virtual surround sink

Now we can put the two together and add the virtual output,

pacmd load-module module-virtual-surround-sink sink_name=vsurround sink_properties=device.description=VirtualSurround hrir=$HOME/.local/share/hrir.wav master=alsa_output.pci-0000_08_00.3.analog-stereo

Note the hrir and master_sink options use the values from steps 1 and 2.

Step 4: Set your default output

Open PulseAudio Volume Control ( pavucontrol ) and verify you can see the new “VirtualSurround” output.

If you want to set this as default, tick the tickbox.

Step 5: Test

Test some audio. I assume you have some 5.1 content otherwise this is pointless. :wink:

Make sure your player is outputting via the VirtualSurround output or you won’t hear any difference.

Step 6: Make it persist across reboots

You can run the command from Step 3 every time you log in, or you can add it to your startup settings.

Open ~/.config/pulse/default.pa and copy the load-module command (without the leading pactl ) to the bottom of the file. Now the VirtualSurround output should be present each time you log in.

If the file does not exist use this template:

#!/usr/bin/pulseaudio -nF

.include /etc/pulse/default.pa

load-module module-virtual-surround-sink sink_name=vsurround sink_properties=device.description=VirtualSurround hrir=$HOME/.local/share/hrir.wav master=alsa_output.pci-0000_08_00.3.analog-stereo

Note: Make sure to replace $HOME with the full path.

Potential issues

Sometimes the sink name can change, especially for USB DACS. This means the load-module command will fail and prevent pulseaudio from loading.
To allow pulseaudio to load, comment out the load-module line and save the file, pulseaudio should start up automatically. After checking the new sink name you can alter and uncomment the line.

Reading and References

[1] https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#index48h3
[2] https://www.reddit.com/r/linux/comments/1oe55t/help_pulseaudio_modulevirtualsurroundsink/

10 Likes