Advanced volume control (amplifier API call instead of bitstream manipulation)
#1
I use kodi for both general HTPC/video duties as well as high-definition audio playback to a high-end'ish audio system. I connect to the audio system from a linux-based kodi build via Coax SPDIF (directly from the linux server), my music is all flac-based with much of the content being 24-bits / 48/96/192 Khz. Audio quality / music experience is awesome.

I use a Flirc-based remote system with a harmony hub + remote, for many years now. The volume remote keys are send as IR commends to the audio system directly; other remote keys are used to control kodi's UI.

As a consequence of this setup, there is no video feedback on the TV when changing the volume, the volume level is not displayed; Kodi's internal volume setting is fixed at 100 to ensure the bitstream sent to the audio system is not touched (audio passthru is also activated)

This works, it guarantees the best possible audio bitstream, but I'm hoping that these days it can be done better and somehow get video feedback on volume changes. My audio system is connected to my home network and has an API, I can easily manage the system via IP, I have it integrated to Home Assistant, for instance, from where I can change volume, switch input etc.

I have been looking for ways to integrate Kodi's audio volume control to my audio system directly, so that Kodi calls an API (or executes a CURL command/script) to set the volume to a specific level, so that:
   - I can get visual feedback on the TV when the volume is being changed
   - the bitstream that kodi outputs is NOT modified in any way  (goes through to the audio system without modification)
   - avoid having to use unreliable and slow infrared directly to the speakers/receiver for volume up/down

Is there a way to achieve this? e.g. hooking bash scripts to kodi's volume changes, in a way that would still display kodi's volume change UI overlay



Note that using audio over HDMI from Kodi/HTPC to TV + TV-Audio out (optical SPDIF) to the speakers wouldn't achieve the goal (volume control would still be needed in my audio system amplifier); my TV has HDMI-ARC however the audio system does not.
Reply
#2
If you know python, you can easily write your own audio overlay window that displays a "fake" volume control, and with this you can control whatever you want. I've done this in my PulseAudioEqualizer to bypass Kodi's volume control to feed a compressor and have the volume changed after the compressor.
Reply
#3
It's a great idea! I should be able to detect volume changes via the API directly or via HomeAssistant and call a script. Yes I use python for most of my code and having a sample on how to display the overlay would be awesome, if you could share it. Currently I am using Kodi standalone on X11 (with openbox as window manager) but planning to switch to GBM in my upcoming new build. So ideally the overlay will be Kodi-native.
Reply
#4
Be warned, the example I have is part of a bigger project, that uses sockets for communication, minimizes the direct addon code and loads most of the stuff as service staying in memory due to performance reason on small devices such as raspberry and also to overcome precompile issues for the Kodi python interpreter and on top generates dynamic XML for stability and flexibility. All of this you don't need, if your machine is powerful enough.

So it might be better for you, to build something from scratch, there are plenty examples.

In principal you need a window xml-file like this including some progress image like this.

A python class file that defines the behavior of the overlay window like this.

An addon xml that defines ýour addon like this

And a the "addon.py" that gets launched by predefined keys with different parameter like volume up / down and then itself launches the window class.

Good luck.
Reply
#5
Thanks @wastis! This helps. I will be looking into this in the coming weeks. My use case could be a little simpler as the machine is indeed quite powerful, not a raspberry (n100)
Reply

Logout Mark Read Team Forum Stats Members Help
Advanced volume control (amplifier API call instead of bitstream manipulation)0