Set Hifiberry hardware mixer as default volume control

I have a Hifiberry Amp2, which appears to be exactly the same chip as the DAC+. I enabled the DAC+ overlay in My OSMC, and set the audio output to that, and I get sound out just fine.

However, the Kodi volume control is (I believe) a software mixer, and it isn’t controlling the main hardware volume mixer of the Amp2, which is listed in alsamixer as “Digital”.

When I change the volume in Kodi that mixer doesn’t change, though I do hear a difference in volume. It’s just limited to whatever I’ve set the volume to in alsamixer. I don’t like this, since it means I either have to SSH in and use alsamixer (which is a pain obviously) or I have to keep that at maximum and use Kodi’s volume control, which is also not ideal since it’ll negatively affect signal-to-noise ratio.

Is there a way to get OSMC/Kodi’s volume control to directly control this particular audio mixer control?

AFAIK, there is no easy way to link the kodi volume control to a hardware control. If there is a way, the kodi wiki/forum would be the place to ask. If want to dig through the code, it’s possible Android kodi might do this.

BTW, I would expect the ‘Analogue’ control to be the one that works downstream of the DAC, which is presumably what you want to vary for best quality.

I actually posted on the Kodi forum just a couple of hours ago. As you suspected, it looks like this feature does not exist. Digging through code for it is more than I’m willing to do at the moment, though if I find no other solution I’ll eventually give it a go.

As for the control to use, I don’t think so: the “Analogue” one only has two steps: 0 and -6dB. The one labelled “Digital” is the only one which seems to give the full range.

I found this old merged pull request which added this feature among others:

check whether a CEC capable amp is avaiable on the bus. when one is found, the PCM volume is set to 100%, and all volume related changes (vol up, down, mute) are sent to the amp.

I wonder if I can leverage that. Any idea if it’s possible, on the same machine running OSMC, to fake the presence of a CEC-capable amp, intercept the volume control signals Kodi is sending to it, and run amixer commands when they’re received to control a particular mixer?

I think if this is possible it would be a really great feature for OSMC to have.

I suspect nigh-on impossible out of the box. Every soundcard is different so there would have to be a bit of self-assembly.

Maybe for USB soundcards which are relatively standardised…

Oh totally, you’d configure it with the hardware device and mixer name, just as you configure MPD to use a hardware volume mixer.

Interesting. I took a look at this some time ago, as I wanted to get volume buttons on the new OSMC Remote to control the AV via CEC. I didn’t realise so much functionality had already been merged in to Kodi.


Did you get anywhere with it?

Haven’t really looked in to it just yet