0

Using pipewire or wireplumber how can we make an stereo output device became mono by combining the left and right channel ?

This particular question seems silly, but its very useful, be that your speaker can't reproduce stereo, or for accessibility reasons, we all should have an option to easy toggle mono output on our system. But yeah, we don't have that option with GNOME, yet.

Following the guidelines, I'll answer this question that I had myself.

So this is specific for pipewire since I'm using Ubuntu 23.04 and its the default audio server been used. After searching a lot, I couldn't find any answer to this simple question using pipewire or wireplumber. So after finding a way of making an option appear on the output devices of Gnome-Control-Center audio setting to use a mono output with a name that I choose, I'll share with you guys the steps that I had to take to get there.

  • maybe already asked here https://askubuntu.com/q/1439652/1067350 , what should I do ? The only difference is that there is Kubuntu and here GNOME Ubuntu – Eduardo Moraes Sep 07 '23 at 18:27

1 Answers1

0

So to achieve true mono from a stereo output we need to tinker with pipewire config.

This is the part of the pipewire documentation that helped me to achieve the desired mono sink: Pipewire - Module Combine Stream

So first we need to find out what are the name of our node.device to use in our config file, as said in WirePlumber - ArchWiki from the terminal run:

$ wpctl status

PipeWire 'pipewire-0' [0.3.56, user@hostname, cookie:1163266174]

Audio ├─ Devices: │ 42. HD Audio Controller [alsa] │ 105. USB PnP Audio Device [alsa] │ ├─ Sinks: │ * 48. HD Audio Controller Analog Stereo [vol: 0.50] │ ├─ ... │ ├─ Sources: │ * 101. USB PnP Audio Device Mono [vol: 0.74] │ └─ ...

The ones marked with an * are the ones that your are current using, we are looking for the sinks, the number indicates the id, so we can use $ wpctl inspect [ID]

$ wpctl inspect 48

id 48, type PipeWire:Interface:Node ... ...

  • factory.id = "18" factory.mode = "merge" factory.name = "api.alsa.pcm.sink" ...
  • media.class = "Audio/Sink"
  • node.description = "HD Audio Controller Analog Stereo"
  • node.name = "alsa_output.pci-0000_08_00.4.analog-stereo"
  • node.nick = "ALC1220 Analog" ...
  • object.path = "alsa:pcm:1:front:1:playback"
  • object.serial = "49" ...

We are looking to get the node.name

So now that we gather everything, we can combine the information from both wikis.

  • In your distribution folder of pipewire(usually /usr/share/pipewire), find the pipewire.conf file and add this configuration with the modifications that suits your needs.
  • At the context.modules section:
context.modules = [
{   name = libpipewire-module-combine-stream
        args = {
            combine.mode = sink
            node.name = "combine_stereo_to_mono_sink" # Can be any name of your choice
            node.description = "Mono Speakers" # This is the name that will appear in the sound settings
            combine.latency-compensate = false
            combine.props = {
            audio.position = [ MONO ]
            }
            stream.props = {
                stream.dont-remix = true
            }
            stream.rules = [
            {   matches = [
                    {   media.class = "Audio/Sink"
                        node.name = "alsa_output.pci-0000_08_00.4.analog-stereo" # Your node.name here
                    } ]
                    actions = { create-stream = {
                            audio.position = [ FL FR ]
                            combine.audio.position = [ MONO ] # These both are what combine both channels into one
                    } } }
            ]
        }
    }
]

You can either just copy the part inside context.modules=[] or create a new file and add to the pipewire.conf.d or pipewire-pulse.conf.d directories.

After saving the file, either reboot your system or restart pipewire and wireplumber:

$ systemctl --user restart pipewire pipewire-pulse wireplumber

This is my sound settings: Mono Speakers Mono Speakers2

  • The solution written here askubuntu.com/q/1439652/1067350, didnt work for me. This one that I posted works 100% of time. If you are not listening to audio, you can first select your normal stereo output from the settings, then select the Mono Speakers. (I need to do this after I change to my headphone amplifier, so first i select the normal stereo output, then the mono that we created) – Eduardo Moraes Sep 18 '23 at 18:46