[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/

11 Likes

Thank you for this tutorial, i was looking for something like this for my headphones. :grin:

Also i like to point out that there is a typo, it’s not “master_sink” is “master”, with that change i was able to make the commands work. I was little lost trying to find what i didn’t put correctly. :sweat_smile:

1 Like

Sorry for this bump, but I wanted to ask, does this also work for 7.1 headphones?

I can't see why not. Why not try it and find out?

I meant that, according to that quote up there, I assumed these hrirs were only for 5.1 channels. Cause I got it to work anyway, but it doesn't sound satisfactory yet, so I'm gonna have to experiment with different hrirs, but do they work on 7.1 content as well?

Also here's a small note for anyone going through this - remember to use the full path for the hrir location in the command in the 3rd step, relative paths do not work

The sound quality is awful! Is there better way to do it on Linux now?

Not as far as I've seen. This is probably the best available right now. Just pick the HRIR that sounds least bad best and pray it sounds better with surround content than ordinary stereo.

It seems like it still doesn't support 7.1 channel.
By the way, the front right and rear right always sounds the same to me.
Is there any way to gain more depth of the sound?

A post was split to a new topic: How to not output 44.1kHz when I'm not using the Virtual Surround effect?

Forum kindly sponsored by Bytemark