How to invert left and right sound channels on the fly

by Rudd-O published 2016/03/18 10:40:00 GMT+0, last modified 2016-03-18T10:39:02+00:00
Sometimes you need to diagnose a particular problem with your stereo's setup, or your headphones, or the speakers of your laptop. Maybe one of the sides sounds louder than the other, maybe you think you have a blown tweeter, maybe it's the audio signal currently playing? Here's a trick to test that without reconnecting any cables or adding any hardware to your setup.

First of all, install the two programs pavucontrol (PulseAudio volume control) and paman (PulseAudio manager).  You can use your Linux distribution's package manager for that.

Now, launch the PulseAudio manager from your menu or a terminal.  The very first screen will show the Default Sink value.  Copy that to the clipboard.

You can now run the following program on your terminal:

sink=<paste your Default Sink value here>
pactl load-module module-remap-sink \
  sink_name=remapper \
  master=$sink channels=2 \
  master_channel_map=front-left,front-right \

This loads a module into your current session that creates a new, "fake" sink to play audio into.  Only this sink inverts left and right, transparently, for your benefit.

Now launch the PulseAudio volume control.  You will see a list of current programs playing audio streams, with one slider each, and a button right above the slider that mentions the name of the current sink for the stream.

Begin playing the audio that you wanted to hear over the speakers / headphones.  You should see the stream appear and a VU meter bar move.

Now invert it!  Click on the button holding the current sink for the stream, and select the Remapper sink.  You should hear left and right switching, instantaneously.  Using the exact same technique, you can now flip back and forth between the original sink and the remapper, which should flip left and right channels for you.  No delays, no having to reconnect any cables, no extra hardware.

Similar tricks can be played by piping audio to all sorts of virtual sinks, including sinks that equalize audio, or sinks that impart audio effects to the streams being played through them.  To learn more, visit the PulseAudio modules page.