PipeWire/Examples

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Surround sound systems

Splitting front/rear

When using PipeWire as a PulseAudio/JACK replacement, you can set up Pipewire to replicate the Pulseaudio example for splitting front/rear. Doing this allows you to send audio streams using Pulseaudio to a separate sink for speakers or headphones.

Connect speakers to the line-out port and headphones to the rear port. In pavucontrol set the soundcard used to Analog Surround 4.0 Output. Then using the following commands, make new sinks for the speakers and for the headphones, link the speakers to the front channels and link the headphones to the rear channels:

 pactl load-module module-null-sink sink_name=speakers object.linger=1 media.class=Audio/Sink channel_map=FL,FR
 pactl load-module module-null-sink sink_name=headphones object.linger=1 media.class=Audio/Sink channel_map=RL,RR

object.linger=1 keeps the sinks alive after the creating client disconnects. You can name sink_name whatever you want.

In order to unload module, you can use pw-cli destroy ID, where ID is output of pactl load-module command. Unloading individual modules through pactl unload-module is not currently supported [1]. However, you may use it to unload all module-null-sink modules using pactl unload-module module-null-sink.

Using jack_connect, connect the monitors of the new sinks to the sound card's playback ports. Find out the name of the channels by running jack_lsp -c.

 pw-jack jack_connect speakers:monitor_0  HDA\ ATI\ SB:playback_FL
 pw-jack jack_connect speakers:monitor_1  HDA\ ATI\ SB:playback_FR
 pw-jack jack_connect headphones:monitor_0  HDA\ ATI\ SB:playback_RL
 pw-jack jack_connect headphones:monitor_1  HDA\ ATI\ SB:playback_RR
Tip: Add the above commands to a script and autostart it to automate the process. Be sure to replace HDA\ ATI\ SB with the name of your sound card.
Note: The Jack/Pipewire sinks seem to change name now and then. In the above example, HDA\ ATI\ SB:playback_FL sometimes changes into Built-in\ Audio\ Analog\ Surround\ 4.0:playback_FL. As a quick workaround, you could add a second set of pw-jack commands in your autostart script with the second set of names.

To individually control the volumes, one option is to use alsa utilities (such as amixer) to control Front and Rear/Surround (alsa naming) channels. A script to automatically do that depending on what is your currently default pulseaudio sink can be found here.