easyeffects icon indicating copy to clipboard operation
easyeffects copied to clipboard

Autoload preset on software output swap

Open CubeTheThird opened this issue 5 months ago • 4 comments

To my understanding, the autoload preset option is only triggered when a device is added/removed (e.g. plugging in headphones) and I am wondering if it is possible for the same thing to happen when manually changing devices through the Device Management section.

Now for the lengthy context for this question.

My goal, in essence, is to be able to swap output devices and EQ profiles at the same time, with the click of a button. I have headphones and speakers plugged into my PC at the same time, and have no need to unplug them. By default, my system treats these two ports as the same audio device, in a way that does not even allow EasyEffects to swap between them. Through some configuration with the Jack Retasking tool, I can merge these ports so that they appear as Front and Back audio devices of a 4.0 audio setup. With this, I can create virtual sinks for each port, then point EasyEffects to the appropriate one to route the audio. The setup resembles this:

Audio Source --> EasyEffects --> Virtual Sink (headphones or speakers) --> HD audio controller --> Speakers/Headphones

This does work, however I am stuck at the ability to swap devices. I am using Gnome Shell, and thus have access to the shell extension for quick profile swapping. Unfortunately it does not swap devices too. Thus I am left with some questions:

Can/should EasyEffects auto swap both device and profile at the same time? Is this something I should bring up with the shell extension developer instead? Is this the best way to solve this problem?

I am fully open to ideas and suggestions, as this is something I've been experimenting with, but I am by no means an expert when it comes to pipewire.

CubeTheThird avatar Jul 24 '25 00:07 CubeTheThird

Hum... As things are right now we rely on PipeWire emitting a "device routing changed" signal https://github.com/wwmm/easyeffects/blob/feffc735cd81ba8980deb57e6293d83e5fc60951/src/application.cpp#L146. So anything that triggers that should work. As far as I remember this signal is also emitted when the default device changes.

By default, my system treats these two ports as the same audio device, in a way that does not even allow EasyEffects to swap between them.

It is probably the kind of hardware where the soundcard driver does not create independent devices for headphones. It just changes the routing of the current device to the one related to the headphone.

Can/should EasyEffects auto swap both device and profile at the same time?

Based on what I have seen in the last years the way that works for most people is the one we use now that relies on PipeWire emitting the routing changed signal. In the past a solution based on the node name failed on hardware that just change the routing while keeping the node name intact.

Is this something I should bring up with the shell extension developer instead?

The most the extension developer can do is offering a way to select hardware routing profiles. Pavucontrol allows this to be done for example. So it is possible. What I do not remember now is what Pipewire does in the case of virtual devices. I do not think they actually have a routing property. And as EasyEffects only cares about routing changes coming from the device it is using as output/input this is a problem for your configuration. If no routing changed signal is emitted when changing which hardware is connected to your virtual sink EasyEffects autoloading will never work.

wwmm avatar Jul 24 '25 00:07 wwmm

Thank you for the quick and concise reply. This makes a lot of sense. I may have to investigate whether it's possible to simulate or trigger one of these "device routing changes" through pipewire.

My alternative thought, along the lines of the shell extension, is to possibly swap both the profile and output device at the same time. I am however unfamiliar with what mechanism/API is used currently to swap profiles, and whether that could extend to audio device too.

Another thought, maybe as a feature request, would be for a way for presets to work in reverse (in a sense). I.e. when selecting a preset, the associated audio device changes too, instead of the other way around.

CubeTheThird avatar Jul 24 '25 00:07 CubeTheThird

when selecting a preset, the associated audio device changes too, instead of the other way around

It is not impossible to do. But I think this really goes against the tides when considering how the code works right now. EasyEffects has evolved around the idea that routing changes are the ones that trigger or not a preset to be loaded. And considering that it is the first time someone suggests an idea like this it does not seem there will be many benefiting from this feature. It feels like a super corner case.

wwmm avatar Jul 24 '25 00:07 wwmm

Makes sense. Didn't really feel light the best place for that sort of thing anyways.

CubeTheThird avatar Jul 24 '25 02:07 CubeTheThird