upsampling options

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
PES
Posts: 4
Joined: Fri Jul 31, 2020 10:09 pm

upsampling options

Post by PES »

Hello,

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!

User avatar
MichaIng
Site Admin
Posts: 2208
Joined: Sat Nov 18, 2017 6:21 pm

Re: upsampling options

Post by MichaIng »

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 ;): https://unix.stackexchange.com/a/141234

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.

PES
Posts: 4
Joined: Fri Jul 31, 2020 10:09 pm

Re: upsampling options

Post by PES »

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!

PES
Posts: 4
Joined: Fri Jul 31, 2020 10:09 pm

Re: upsampling options

Post by PES »

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?

User avatar
MichaIng
Site Admin
Posts: 2208
Joined: Sat Nov 18, 2017 6:21 pm

Re: upsampling options

Post by MichaIng »

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.:

Code: Select all

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
}

PES
Posts: 4
Joined: Fri Jul 31, 2020 10:09 pm

Re: upsampling options

Post by PES »

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:

https://github.com/mikebrady/shairport- ... LIBSOXR.md

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.

User avatar
MichaIng
Site Admin
Posts: 2208
Joined: Sat Nov 18, 2017 6:21 pm

Re: upsampling options

Post by MichaIng »

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.

Post Reply