Roon DSP Volume vs ALSA Softvol vs "hardware" volume control

I’m using a PCM5122-based DAC (and/or a TAS5756M-based DAC-Amp) with a Raspberry Pi and thus have three options for volume control:

  1. Roon’s DSP Volume software control
  2. The ‘hardware’ volume control exposed via ALSA (the slider called ‘Digital’)
  3. An ALSA softvol plugin software volume control slider

Option 1 (Roon DSP volume) has been described elsewhere on this forum as being a standard, best practice implementation, operating in essentially the same manner as the core DSP engine in Roon (although the reasons for labelling it “high quality” rather than “enhanced” are understood):

a high quality 64bit precision attenuation with dithering

The control range is from 0 dB to -80 dB.

Option 2 (hardware volume) is the default, and in another thread on this forum Brian from Roon wrote:

We manipulate the “Digital” control for pcm512x devices like the HiFiBerry/IQaudIO devices because we’ve been made to understand that this is the highest quality volume control on the device

However, in the datasheet for these devices (PCM5122, TAS5756M), describes the volume control only briefly thus (emphasis added):

A basic digital volume control with range from 24 dB to –103 dB and mute is available on each channel […] These volume controls all have 0.5-dB step programmability

The control range for the slider in ALSA is 0 dB max, rather than the +24 dB the chip can do (thankfully). Roon doesn’t mark it as degrading the data path (i.e. it shows “enhanced”, “lossless” or whatever).

Option 3 is the ALSA software volume control plugin. It’s not clear to me exactly how it works (in terms of bit depth or dither), but the range and resolution of the slider is user-definable, which is convenient. Roon doesn’t really know this is any different to the hardware volume slider in ALSA (above), so it also doesn’t mark it as degrading the data path.

For the hardware volume control to be described as “basic” by the manufacturer is not exactly awe-inspiring (and especially given there is no further information about its operation), and so leads me to want to use either Roon’s DSP volume or ALSA’s softvol plugin.

My questions around this are:

  1. How does the ALSA softvol plugin compare to Roon’s DSP volume? (which is ‘technically’ better?)
  2. Can anyone (perhaps someone knowledgable at Roon) offer any more insight into the ALSA softvol plugin? Does it use 64-bit internal precision? Does it dither?

I took a look at the ALSA softvol implementation.

It does not appear to dither, even when outputting at 16bits. This is likely audible in some scenarios.

It also does not appear to compensate for the DC offset that is naturally introduced during truncation when reducing precision back to the final integer sample value.

Whether it is “64bit” or not is actually not an important question. The right question is: is the math done at a precision that does not lose information due to the size of the intermediates. The ALSA code is a little bit obtuse, but it appears to have adequate precision at the intermediate stage. The bigger problem is how the output is handled.

A volume control like this should not use the same format for input and output. It should take the source material as input, and output at the maximum bit-width that the downstream hardware device can support. This way, you can attenuate quite a lot without destroying any significant figures.

Most audio devices can accept 32bit samples. Source material is usually 16-24 bits. It’s nice before applying attenuation to expand the sample dimensions to the max that the device can support, to make sure that when we make it quieter, we aren’t actually losing data

xxxxxxxx xxxxxxxx xxxxxxxx          <- 24 bit sample
xxxxxxxx xxxxxxxx xxxxxxxx 00000000 <- 24 bit sample expanded losslessly to 32bits
0xxxxxxx xxxxxxxx xxxxxxxx x0000000 <- -6dB
00xxxxxx xxxxxxxx xxxxxxxx xx000000 <- -12dB

See how by creating that extra space at the least significant end of the numbers, we are keeping all of the data and preserving the same number of significant figures? I picked round numbers to make the point, but with enough headroom, even non-round adjustments (i.e. not multiples of 6dB) preserve the same amount of information.

The ALSA plugin always takes Xbits of input and produces Xbits of output, so by default, it is throwing data in the trash as soon as you start making things quieter. It might be possible to wire up multiple plugins to make sure that the stream is expanded before going through volume processing, but they are leaving it to you to think about it and get that right, whereas Roon works out the best topology for you automatically and makes it impossible to get it wrong.

ALSA is a general purpose toolkit who’s main job is to make things work no matter how weak the device. It really doesn’t concern itself with making things sound good–people who want that use ALSA as a bit-perfect conduit and manage these concerns externally. Roon is a music player built with sound quality as a primary design goal. It’s not a big surprise that they are different.

TL;DR: I don’t trust any of the DSP within ALSA when quality matters. It wasn’t built with our needs in mind. I have no qualms about using Roon’s volume control when there’s a reason to do so.

1 Like

Excellent, thanks for the explanation (and taking the time to peek into the ALSA code for it), much appreciated!