Surround sound systems
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 . However, you may use it to unload all
module-null-sink modules using
pactl unload-module module-null-sink.
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
pw-link speakers:monitor_1 alsa_output.pci-0000_00_14.2.analog-surround-40:playback_FL pw-link speakers:monitor_2 alsa_output.pci-0000_00_14.2.analog-surround-40:playback_FR pw-link headphones:monitor_1 alsa_output.pci-0000_00_14.2.analog-surround-40:playback_RL pw-link headphones:monitor_2 alsa_output.pci-0000_00_14.2.analog-surround-40:playback_RR
alsa_output.pci-0000_00_14.2.analog-surround-40with the name of your sound card. Adding a delay before the script executes may also make things work smoother.
alsa_output.pci-0000_00_14.2.analog-surround-40:playback_FLsometimes changes into
Built-in\ Audio\ Analog\ Surround\ 4.0:playback_FL. As a quick workaround, you could add a second set of
pw-jackcommands 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.