You are not logged in.

#1 2024-07-15 15:46:34

schmidtbag
Member
From: NH, USA
Registered: 2011-02-08
Posts: 344

Automatically switch PA profile based on application *SOLVED*

I have a 5.1 surround receiver connected by HDMI.  When doing a stereo output, the receiver's DSP does an excellent job at turning mono or stereo audio into a pretty dynamic and enjoyable surround experience.  However, it *only* works that way when setting the profile to "digital stereo".  If I set it to "digital surround 5.1", I lose the receiver's DSP.  I set my /etc/pulse/daemon.pa to have "enable-remixing = no", thinking that forcing it to be stereo channels would help, but it just simply limits the channels to front left and front right.

I assume the problem is that all 6 channels are being transmitted whether they carry audio or not, so the receiver thinks to interpret that literally.  However, there's plenty of applications/media I have where they're always going to be stereo.  Does anybody know of a way where the channel configuration can be changed on-the-fly based on the specified applications, but otherwise default to a 5.1 output?  I'm not opposed to doing the inverse, if that's easier.


EDIT:
Unless somebody else has a better idea, I've already come up with simple a workable solution by piecing together other outdated/broken suggestions made from posts over many other forums throughout the past decade.  In my example, I'm defaulting to stereo but swap to surround sound when running VLC:

1.  Run the following to identify the appropriate device index and all applicable profile names:

pacmd list-cards | grep -e "index" -e "output" | cut -f1,2 -d':'

If the output seems off, remove the cut command.  That's there to remove any extraneous details about the profile that we don't need but perhaps this differs in other systems.
2.  Create a shell script (I called mine "/usr/local/bin/enable-surround") that we put in front of the binary we want to run in surround:

#!/bin/bash

/bin/pacmd set-card-profile 0 "output:hdmi-surround-extra3"
$1
/bin/pacmd set-card-profile 0 "output:hdmi-stereo-extra3"

Obviously, swap out "hdmi-_____-extra3" with whatever your profile is, and then update the permissions to be executable.
3.  For any application you want to switch to the surround profile, just run "surround-enable vlc" or whatever program you want.


If you want certain games in Steam to automatically swap, do the following:
1.  Right-click on the title you want to be in surround and select Properties.
2.  In the General tab, go to the Launch Options and enter the following:

pacmd set-card-profile 0 "output:hdmi-surround-extra3"; %command%; pacmd set-card-profile 0 "output:hdmi-stereo-extra3"

Like before, swap out the profile name with the one you want.
It's important you do semicolon after %command% since that will force the swap to stereo to happen even if the game closed "ungracefully".

Last edited by schmidtbag (2024-07-24 15:13:00)

Offline

Board footer

Powered by FluxBB