software mixer - mpd or alsa?

Need help with MPD?
Post Reply
matt_garman
Posts: 4
Joined: November 13th, 2016, 9:50 pm

software mixer - mpd or alsa?

Post by matt_garman » May 30th, 2018, 2:55 pm

This is the audio_output section of my mpd.conf:

Code: Select all

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:0,0"
        mixer_type      "software"
}
This is for a Raspberry Pi with an I2S DAC that does not have a hardware mixer. So I'm using the software mixer to control volume. Everything works as expected.

I was hoping to get a little more detail on how the software mixer (which I'm using for volume control) works. Is the volume adjustment done by MPD or by ALSA? I'm assuming MPD since it doesn't look like I have any ALSA mixer devices on my system.

What I'm looking for is a way to get a little more fine-grained volume control. With my I2S DAC, the usable volume range is the lower 25%. So I was wondering if there was a way to hack the software mixer to make the volume jumps smaller at the lower end.

max
Forum team
Posts: 953
Joined: January 15th, 2013, 3:43 pm

Re: software mixer - mpd or alsa?

Post by max » May 30th, 2018, 6:46 pm

MPD does it. You can of course hack the source code, it's https://github.com/MusicPlayerDaemon/MP ... Plugin.cxx

matt_garman
Posts: 4
Joined: November 13th, 2016, 9:50 pm

Re: software mixer - mpd or alsa?

Post by matt_garman » May 31st, 2018, 9:34 pm

OK, thank you. If I understand that code correctly, looks like you map what I'll call "human readable volume", in the range 0 to 100%, to "computer volume": 0 to 1024. Looks like it's done in such a way that the jumps are smaller at the lower end too. So no easy/obvious fix for my purposes.

I noticed the documentation talks about filters, but it seems pretty terse. If I want to mess around with different ways of controlling the volume, short of hacking and recompiling the actual MPD source, is there perhaps an easier way with this filter facility? E.g., can I perhaps build a shared library or some other "plugin" that MPD can use for volume control? Is there a defined API for something like this?

For a different project, I have messed with the Dummy mixer, and in turn run an ALSA event listener program to send commands via serial to a hardware device. But in this case, my hardware does not support volume adjustments of any sort. But could I perhaps use a similar strategy to mess with the actual ALSA stream in real-time?

max
Forum team
Posts: 953
Joined: January 15th, 2013, 3:43 pm

Re: software mixer - mpd or alsa?

Post by max » June 1st, 2018, 5:33 am

Internally, software volume is implemented as a filter plugin (controlled by the according mixer plugin). So it is already happening this way. This requires hacking the MPD source and recompiling MPD. MPD has no plugin ABI; there is no way to load shared libraries which provide plugins. Plugins must be part of the "mpd" binary.

henryspencer
Posts: 6
Joined: May 5th, 2018, 6:49 pm

Re: software mixer - mpd or alsa?

Post by henryspencer » June 1st, 2018, 8:03 pm

Would a MPD client with settings to control the amount of steps of the volume be a temporary solution, that would let you change the volume in a minimum of 1% increments but affects the entire volume range. The latest version of Cantata (2.3.0) has a GUI options for this. MPD Remote for android also supports this. Probably other clients also...

max
Forum team
Posts: 953
Joined: January 15th, 2013, 3:43 pm

Re: software mixer - mpd or alsa?

Post by max » June 1st, 2018, 10:05 pm

I don't understand.

henryspencer
Posts: 6
Joined: May 5th, 2018, 6:49 pm

Re: software mixer - mpd or alsa?

Post by henryspencer » June 2nd, 2018, 11:48 am

From what I understood Matt was looking for a way to make the volume jumps (or steps) smaller at the desired first 25% of the volume range. Some MPD clients (gmpc, cantata etc) default behavior is to change the volume in 5% jumps/steps making the first 25% of the volume range fairly crude in volume settings. However clients like Cantata can change this behavior to set the volume in a minimum of 1% jumps/steps making the volume control a little more fine grained.

Post Reply