Skip to content

Feature: add --volume-controller, which enables LVA to use pipewire for master volume control. USB audio natively with LVA!#272

Open
machineonamission wants to merge 35 commits into
OHF-Voice:mainfrom
machineonamission:main
Open

Feature: add --volume-controller, which enables LVA to use pipewire for master volume control. USB audio natively with LVA!#272
machineonamission wants to merge 35 commits into
OHF-Voice:mainfrom
machineonamission:main

Conversation

@machineonamission

Copy link
Copy Markdown

instead of setting libmpv volumes, it sets the external pipewire sink directly. the main benefit of this is that pipewire integrates with ALSA which integrates with USB devices, so you can look at and see changes to the LVA volume from USB audio devices

demo:

PXL_20260327_214123047.mp4

@lowlyocean

Copy link
Copy Markdown
Contributor

Thank you for putting this behind a flag - I would not want the default behavior to be changing hardware device volume, because I share that hardware device with multiple applications that each need a different volume level

@Solarunit

Copy link
Copy Markdown

Yup! I need only libmpv volume for my setup. But good option to have.

@florian-asche

Copy link
Copy Markdown
Collaborator

While seeing the need for this feature i rather want to have it as an addon. We want to make the code more modular and i would like to move this into the backlog until we have that done.

@florian-asche florian-asche self-assigned this Mar 28, 2026
@florian-asche florian-asche added the enhancement New feature or request label Mar 28, 2026
@machineonamission

Copy link
Copy Markdown
Author

While seeing the need for this feature i rather want to have it as an addon. We want to make the code more modular and i would like to move this into the backlog until we have that done.

i get that, but since modifying the calls to libmpv code is a bit invasive (since i have to prevent calls to libmpv's volume!), it would be hard to do this purely modularly. it is behind a flag that is off by default after all. unless the set_volume function (which didn't even fully exist till i added it) could be pulled out and overridden, this would be hard to modularize

@omaramin-2000

Copy link
Copy Markdown
Collaborator

We're working on sending external commands to LVA that can control volume, so wouldn't this one help? #266

@machineonamission

Copy link
Copy Markdown
Author

ok these new commits make it so it doesn't depend on wireplumber anymore, it purely uses pactl/pulseaudio

# Conflicts:
#	README.md
#	docker-entrypoint.sh
#	docs/additional_audio_settings.md
#	docs/install_application.md
#	linux_voice_assistant/__main__.py
@florian-asche

Copy link
Copy Markdown
Collaborator

I don't think writing the pactl output to stdout is the right long-term approach.

Instead, we should introduce a proper abstraction for audio device management and use a library/API to query and control PulseAudio/PipeWire directly. That would be more robust, easier to maintain, and avoids relying on parsing command output.

I'd prefer to solve this in a follow-up by adding a dedicated library-based implementation rather than extending the stdout approach.

# a bit verbose but otherwise robust and awk/grep/regex-less
# no get-sink-volume does not support -f json, otherwise i would have DONE that
def_sink = await get_stdout("pactl", "get-default-sink")
sinks = json.loads(await get_stdout("pactl", "-f", "json", "list", "sinks"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think writing the pactl output to stdout is the right long-term approach.

@omaramin-2000

Copy link
Copy Markdown
Collaborator

My feedback on this is that it will affect the MPV media player volume. So we should keep the system volume itself always at maximum in order to have free control of the media player via the HA entity.

@machineonamission

Copy link
Copy Markdown
Author

My feedback on this is that it will affect the MPV media player volume. So we should keep the system volume itself always at maximum in order to have free control of the media player via the HA entity.

Not doing this is the entire point of this pull request, and why it's disabled by default, and why this PR makes the HA entity reflect the system volume

The idea is by changing the system volume, specific USB hardware devices will be able to read and write to that volume

@machineonamission

Copy link
Copy Markdown
Author

I don't think writing the pactl output to stdout is the right long-term approach.

Instead, we should introduce a proper abstraction for audio device management and use a library/API to query and control PulseAudio/PipeWire directly. That would be more robust, easier to maintain, and avoids relying on parsing command output.

I'd prefer to solve this in a follow-up by adding a dedicated library-based implementation rather than extending the stdout approach.

If I remember right, I chose the stdout approach to avoid adding another dependency

I can look into libraries. Do you know of any?

@omaramin-2000

omaramin-2000 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

You can keep the system volume itself at maximum to just control the media player entity, like everybody does, rather than limiting the mpv player volume by hard control.

@machineonamission

Copy link
Copy Markdown
Author

You can keep the system volume itself at maximum to just control the media player entity, like everybody does, rather than limiting the mpv player volume by hard control.

Right, which is still the default behavior.

@florian-asche florian-asche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need changes here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants