Hardware volume control of IQaudIO Pi-DAC

I’m not sure if this is to be classified as a bug or feature request, mods please feel free to correct me if I’ve posted in the wrong spot!

I’m using the IQaudIO Pi-DAC, and am more than happy with how it runs and sounds! The only major gripe I have though is controlling the hardware volume control of it via the Volumio web interface. As others have mentioned, it doesn’t sound linear to the ear. Controlling the volume via alsamixer however is close to perfect though, it maps the percentage scale correctly.

Playing with the amixer command I found there is a -M option:
“-M Use the mapped volume for evaluating the percentage representation like alsamixer, to be more natural for human ear.”

For example when setting a 50% volume level, the following:

amixer -c 1 sset "Playback Digital" 50%

Sets the volume exactly the same as setting the UI volume dial to 50%, and is barely audible at all:

[root@runeaudio ~]# amixer -c 1 sget "Playback Digital" Simple mixer control 'Playback Digital',0 Capabilities: volume pswitch Playback channels: Front Left - Front Right Capture channels: Front Left - Front Right Limits: 40 - 255 Front Left: 148 [50%] [-49.50dB] Playback [on] Front Right: 148 [50%] [-49.50dB] Playback [on]

But using -M instead:

[root@runeaudio ~]# amixer -c 1 sset "Playback Digital" 50% -M

Gives this result, which matches very closely to the 50% volume level of alsamixer:

[root@runeaudio ~]# amixer -c 1 sget "Playback Digital" Simple mixer control 'Playback Digital',0 Capabilities: volume pswitch Playback channels: Front Left - Front Right Capture channels: Front Left - Front Right Limits: 40 - 255 Front Left: 218 [83%] [-14.50dB] Playback [on] Front Right: 218 [83%] [-14.50dB] Playback [on]

I’m not sure how the Volumio UI actually sets the volume level once the user has touched the volume control, but if it could be set to use this amixer command with the -M option (or something similar) would that be a way to get the correct volume control mapping?

Failing this, perhaps some kind of manual mapping or lookup could be used, so that for each value from 0 to 100 in the UI, the software looks up a correctly mapped volume level between 40 and 255.

I’m completely new to linux so if anyone has any info on how to implement a manual fix please point me in the right direction. I hope this info helps!

Thank you Fin! I’m looking at it right now!

I’ve looked at the mapping used by alsamixer and amixer -M and figured out the function they use to map the hardware volume level to a natural sounding curve.

IQaudIO’s Pi-DAC has 216 integer steps to its volume control, min 40 to max 255. (I’m guessing other DACs would vary?) In another post Gordon mentioned this gives a dB range from min -103.5dB to max +4dB.

Mapping a percentage volume (ie volume value from min 0 to max 1) to integer:
integer = 120 x log(volume) + 255 (rounded down to nearest integer)

Mapping instead to a dB value:
dB = 60 x log(volume) + 4 (rounded down to nearest 0.5dB)

Could the code behind the user interface take the volume level, then convert it using either of these functions before setting the hardware volume?

Also could a max volume be set, ie to match the input sensitivity of an amplifier?

It would be really cool if a max volume could be set (or a volume mapping) because at the moment setting a 100% volume on the webUI equates to +4dB, which causes audible glitches. For better SNR I prefer to have the DAC volume maxed and control volume on the power amp, but it would be nice if the UI would stop it going above 96% ie 0dB.

There is still something wrong with the volume IQaudio pi-dac+ on 50 on the webinterface the volume its around 0?

Was a fux ever made for this? I am suffering with the same issue. I do not have a pre amp so really need to address this.

Is volumio responsible for setting the volume via alsa or is mpd?

You can SSH to volumio and set alasmixer. sudo alsamixer . 86 is the Max to get 0 db. So set it lower. You can unchecked volume boost ( don’t remember exactly term). All information are available at http://www.iqaudio.com/downloads/IQaudIO.pdf.

Using alsamixer is clunky and is the same as using the gui, set to 86.

Fortunately rpi kernel 3.18 fixes this with a switch in alsamixer ‘Analogue’ that toggles 0db or -6db at full output. Which is great., set and forget.

Unfortunately in rpi kernel 3.18 the renamed the volume control mixer to ‘Digital’ which works in alsa mixer but Volumio GUI not longer targets the right mixer. Therefore the volume control in the GUI is broken.

I’ll raise a new bug as this change will not be reverted in the upstream kernel. Advice is the user space app should use ucm. bugzilla.kernel.org/show_bug.cgi?id=99631