upsampling options


Is there anyway to globally upsample audio using either SoX or libsamplerate? I’m pretty sure if there was an option for Pulseaudio output it could be one easily. Basically I would like to see the options that we have under the audio settings for MPD, work for all audio plays through the system. If anyone knows how to do this please let me know.

Thanks in advance!

This would be the way to go, means you need to edit /etc/asound.conf accordingly and note that dietpi-config > Audio Options selections will overwrite it :wink::

You’ll find the pcm.!default in our default /etc/asound.conf, edit it as shown in the link and add the pcm.device block to the top of the file.

Thanks for the tip. Would doing that force all source sample rates to the sample rate you set it to?

Another concern is I was reading elsewhere that Alsa on its own does a very lousy job of upsampling. Where SoX and libsamplerate are designed with quality in mind. You can also set it up to only upsample certain rates such as 16/44.1 and leave higher native sample rates alone. Which would be ideal for me. Also with one of the latest Shairport-sync updates, it’s possible to use Pulseaudio on the output to upsample. Is it possible to add Pulseaudio and the Pulseaudio options in the audio settings menu? I think many people would enjoy this flexibility. Thanks!

I tried the trick you shared but could not get it to work. I used Nano to do it. I don’t know anything about Linux. Am I supposed to type “device” where it says “device”? Or does “device” represent the hardware name under soundcards in the audio config menu? Also do I need to add that 2nd command where I slave it to another device as well?

Not sure about ALSA upsampling quality, probably you’re right. It will upsample all sound output that is done through ALSA, but players/sources use something else.

Yes Shairport-Sync can use PulseAudio. I disabled it for our builds (since we don’t use it) but probably I should enable it for user flexibility. However we’ll not add it to our menus/installs as option, it would require a too large rework at many places and at least in theory PA is only a frontend, so you can do everything with ALSA as well.

“device” is just a random name, you can use anything you want, only rule is that must match, e.g.:

pcm.awesome {
    format S24_LE
    rate 96000
    type hw
    card 0
    device 0

pcm.!default {
    type plug
    slave.pcm "awesome"

ctl.!default {
    type hw
    card 0

Thanks I’ll give it another shot. However I did a bit more digging and the Shairport-sync developer added the ability to integrate SoX upsampling with shairport without Pulseaudio. More info here:

I’m not sure exactly how to configure it if you set it up this way. But I can imagine doing what he says to enable it would be easy if you understand how to do it.

Ah yes, Shairport-Sync has internal SOXR support and our packages have it enabled by default. Also check their documentation and the included config file /usr/local/etc/shairport-sync.conf with interpolation = “soxr”;. But to be true I never actively used it so not sure how to further configure exactly, e.g. sampling rate. If Mike can help, that is awesome and we can feed our docs with it.

Great to hear! Please let me know how to set it up. I’m not having any luck the other way. Not sure what I’m doing wrong. SoX is far superior upsampling anyways if we can get it going. It’s more CPU demanding, but theres different quality levels to choose depending on available CPU power.