Having Pulseaudio downmix Surround 5.1 to Stereo

After a good deal of gnashing of teeth, I finally managed to get Pulseaudio to Do The Right Thing™ (which is what the thing I want, not what it wants): downmixing Surround 5.1 to Stereo.

The problem was simple: I had a lot of lossless FLAC files containing Surround 5.1 audio (that is, 6 channels). However, at the moment I only own a couple of speakers which are good enough for casual listening (ergo, 2 channels stereo).

I thus wanted Rhythmbox, Totem, and other apps to simply make me listen to the rear channels; else, I would lose half of the guitar solos in Jethro Tull’s “Aqualung”, because when it was recorded it was spatially at the rear of the room.

Until you don’t know how this is done, it looks harder than it is (as most things are). For the sake of completeness, I should point out that you can force the behaviour you want on the commandline and the right programs; for instance, with mplayer you can pass the “-channels 2” option to force downmixing, and with gstreamer you can use something like:

gst-launch filesrc location=”audio.flac” ! decodebin ! audioconvert ! audio/x-raw-int,channels=2 ! audioresample ! pulsesink

Cool as it is, Rhythmbox and Totem were still oblivious to my efforts. Darn.

Then, it stroke me that I could go all the way down, and add a virtual sink mapping the rear channels to the front channels. Yep, that’s the trick. And yes you can, too!

First check out the name of the master sink that is linked to your analog soundcard. Use “pacmd list-sinks | grep -i ‘name:’” to have a list, and make an educated guess.

Just add at the end of your /etc/pulse/default.pa the following wonderful line:

load-module module-remap-sink sink_name=stereo-downmix master=alsa_output.pci-0000_00_14.2.analog-stereo channels=4 master_channel_map=front-left,front-right,front-left,front-right channel_map=front-left,front-right,rear-left,rear-right

Remember to substitute the name of the master sink with yours.

Now restart pulseaudio with “pulseaudio -k” (might eventually take a bit of nasty killing with “killall -9 pulseaudio; pulseaudio -D“).

Restart your GNOME shell with ALT+F2, and by typing “r” + Enter.

Now go to the Sound Preferences in your Control Center (or click on the loudspeaker icon and select “Preferences”), and select the newly-appeared “Remapped internal audio” as your sink.

Go and play that rockin’ Jethro Tull’s solo!

2 Responses to Having Pulseaudio downmix Surround 5.1 to Stereo

  1. Andy says:

    Thanks for this useful tip! Now I’m able to watch movies encoded with AC3 on my 5.1 system which also has only the both front speakers (plus subwoofer) connected ..and the voices now are much better to understand.

    I used the following line to map the center channel to both, front-left and front-right:

    load-module module-remap-sink sink_name=stereo-downmix master=alsa_output.pci-0000_00_1b.0.analog-stereo channels=6 master_channel_map=front-left,front-left,front-right,front-right,front-left,front-right channel_map=front-left,center,center,front-right,rear-left,rear-right

    Tested on Mint 16, pulseaudio 4.0.

  2. Stefan says:

    Even in 2017, this works fine and helped me out today. Thank you. I put this line in ~/.config/pulse/default.pa, though. So I dont have to touch the systemwide config.

    Done on Archlinux with pulseaudio 10.0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: