Amazon Music streams different tracks at different rates, many above the default bit rate that pipewire ships with. This is how to fix it.
Firstly, I am running the Windows Amazon Music app via Crossover, a user-friendly version of wine. It works, it's stable. Ubuntu 22.04. Getting the app can annoying. Once you have the download file, keep it. The app automatically updates and amazingly this works in Linux too. here are some tips: https://uk.amazonforum.com/s/question/0D56Q0000CMRC0dSQH/amazon-music-desktop-app-deletedmissing
Reduce CPU use: I get much, much lower CPU by turning on the DXVK Advanced Option in the Crossover Bottle setting, which keeps the PC fans almost silent for me. The app has an option to use Hardware Accelarated Rendering. I doubt this works on Linux, and it makes no difference. The app doesn't do much rendering while playing back, perhaps this is more for browsing.
Audio output options: https://imgur.com/a/uUlmHQV
Secondly, I am using the pipewire and wireplumber PPAs I have done this with a number of DACs. Currently I have a Topping E50. I will repeat this setup on my laptop running 23.10, in which case the DAC will be a Topping G5 via USB C.
OK, now onto the pipewire / pulseaudio configuration.
Pipewire can be configured to support multiple rates. For example, according to these instructions. https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Guide-Rates
Don't do that. It only works if the device goes idle, and the Amazon app does not idle the stream between tracks. If you provide multiple bit rates, you'll be stuck with the first value.
Instead, simply change the default.clock.rate
So:
- create a .config directory in your home directory (it almost certainly exists).This is called
~/.config
in the lingo
- make a pipedrive directory in there (ie
~/.config/pipewire
) and cd into that directory - copy the default configuration file:
cp /usr/share/pipewire/pipewire.conf .
We are only modifying one line.
(It is possible to make an "add on" config file that only includes the change of one line, but I won't go into that.
If you want to do that, make sure that you follow the naming instructions, don't call your cutdown file pipewire.conf
)
Uncomment the line:
default.clock.rate
and set it to 192000 (if your DAC supports that rate)
You can make it higher if you wish. Amazon doesn't go higher, but you might have other streams or files that are higher.
That's it. restart pipewire
systemctl --user restart pipewire
Note that if you do this while Amazon Music is player, it will crash and you will have to manually kill processes to clean it up (or if you are using Crossover, quit the Bottle)
Now, you will have todo the usual Linux audio stuff. If your dac is working, it will be an available output device. Amazon Music will let you select the DAC. As far as I can tell, this works the same as letting Amazon Music send to Pulse Audio, and then you use Pulse Audio Volume Control to assign the output to the DAC.
Like a modern Linux user, I am using pipewire underneath. Pipewire pretends to be PulseAudio. That matters if you want to do something more advanced ... pipewire will in most cases be upscaling sampling rates to get 192K since most of the time Amazon plays at lower rates. You might want to request pipewire to spend more CPU on that. The pipewire devs say you won't hear the difference, but what the heck. Now in this case, it matters that pipewire is pretending to be pulseaudio.
In this case, cp /usr/share/pipewire/pipewire-pulse.conf
to the same local directory as above.
Edit the file, and in stream properties, choose resample.quality = 10 (and remove the comment). Max is 14, default is 4.
I don't notice any CPU hit.
quit Amazon Music, and then
systemctl --user restart pipewire-pulse
Topping E50 connection tips
It has been frustrating getting the E50 to connect properly. Once it connects, it's fine. My current idea is to
a) after booting the PC, disconnect the E50
b) set the input to something other than USB
c) reconnect USB
d) change DAC input to USB