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!