We can configure PipeWire to adapt it's global sampling rate to that of the source playing. By default PipeWire will resample everything to a global sampling rate (48kHz
).
So for example when you play music, which traditionally uses 44.1kHz
, PipeWire will internally upsample it to 48kHz
and send it off to your speakers or soundcard using this rate. This isn't bad, Windows does the same thing, but often it's just unnecessary processing and audio is best enjoyed with as little processing done to it as possible.
And even if you're not an audiophile who likes to enjoy their Hi-Res Vinyl rips in lossless quality, this can still benefit you. It can occur that a bug introduces audible artifacts when resampling. Even if that's highly unlikely, if you want to avoid resampling, just follow this guide and configure your system to switch sampling rates based on the source.
PipeWire will either have an editable config file in /etc/pipewire
or not. This can vary depending on distribution but not having this file is not a problem, just follow this guide.
If your system has the config file then there is no need to copy it and you can just skip this next step.
We need to copy the default PipeWire configuration file to a place where we can modify it. If we edit the default in /usr/share/pipewire
then our changes might get overwritten when a PipeWire update gets applied.
$ sudo mkdir /etc/pipewire # create a folder for the config file
$ sudo cp /usr/share/pipewire/pipewire.conf /etc/pipewire/ # copy the default configuration
Open the config file either in a graphical editor or in the terminal using:
$ sudo nano /etc/pipewire/pipewire.conf
You can navigate the terminal UI with your arrow keys and exit and close with Ctrl + X
.
The first one is your general global sampling rate. You can leave this at 48000
, which will be 48kHz
The second value is an array of all allowed sampling rates. Here you can add the sampling rates which PipeWire is allowed to use and change it's global rate to.
44100
or 44.1kHz
is the traditional rate for music in CD-Quality48000
or 48kHz
is the traditional rate for video and movies in DVD- or Blu-ray-Quality. YouTube, Netflix and many other online video streaming services also use this.96000
or 96kHz
is sometimes used for Hi-Res lossless music and can sometimes also be found in Blu-rays. You will likely not need this. Also, many integrated digital to analog converter do not support rates higher than 48 kHz
.192kHz
, 384kHz
, 576kHz
or even 768kHz
as long as your hardware supports it.Just chose the rates you want to use and definde them in the array. Don't forget to add a ,
after each rate except for the last one. If you are unsure, just use the example below, these are fine for everyone and won't cause problems.
## Properties for the DSP configuration.
default.clock.rate = 48000 # default
default.clock.allowed-rates = [ 44100, 48000 ] # sample rates you are gonna use
Chrome likes to internally resample everything to 48kHz. If you want to preserve the sample rate of web content, I recommend using Firefox. For things like Castlab's Electron build (used by the Tidal-HiFi), you can usually get them to playback HiRes audio by setting your default.clock.rate
to the highest one that you'll be using and removing allowed-rates
that are lower.
In my experience the respective Electron-App will still resample everything, but instead of sampling to 48, it'll use the current global sampling rate of your system. If you currently play back music at 48 and pipewire is configured to also run at this rate, then they will use 48, but if pipewire is currently sampling everything to 192, usually it'll adjust and also output 192, atleast that's what PipeWire reports.
But these are just my findings, I might be wrong / things might change in the future. I recommend you try things out for yourself. pw-top
is a nice cli tool for checking what kind of formats pipewire is receiving/sending.
You can restart PipeWire with the following command:
$ systemctl --user restart pipewire pipewire-pulse
If this doesn't work there is always the option to kill the process, it should automatically be restarted by your system in that case:
$ killall pipewire
If you have a fancy DAC it might visually display the sampling-rate on the device or change it's colors. Try playing multiple audio sources like YouTube Videos (48kHz
), YouTube Live, Spotify, CD-rips (44.1kHz
) or Tidal / other Hi-Res streaming services (44.1kHz
, 48kHz
, 88.2kHz
(if you added it to your config), 96kHz
, 192kHz
or even higher). You should* see a your DAC getting different sample-rates for these formats.
*Chrome and Chromium-based browsers use the default global sampling-rate, so maybe try Firefox if you don't see it working with Chrome.
You can also easily check it's current rate by installing easyeffects
and looking in the bottom left of the application.