Pipewire Audio Bitrate Fix

Just upgraded to Zorin OS 18 today and had to make some tweaks to get my desktop DAC to output audio at the correct bitrate. I won't pretend I can hear the difference, but there is a little light on the DAC that tells me what the sampling rate of the output is and I want it at 192.

I don't know anything about Pipewire so I had an AI walk me through this, but I wanted to post it here in case there is anything wrong with these settings that needs to be fixed or if it helps anyone else. The sound is working, sample rate is at 192 on the DAC.

I have a Fosi Audio SK02, so created this file here:
nano ~/.config/wireplumber/main.lua.d/51-sk02-rate.lua

And then added the following contents:

rule = {
  matches = {
    {
      { "node.name", "equals", "alsa_output.usb-Speed_Dragon_Fosi_Audio_SK02-01.analog-stereo" },
    },
  },
  apply_properties = {
    ["audio.format"] = "S32LE",
    ["audio.rate"] = 192000,
    ["audio.allowed-rates"] = "44100,48000,88200,96000,176400,192000",
  },
}
table.insert(alsa_monitor.rules, rule)

And then restarted WirePlumber with:
systemctl --user restart wireplumber


Before that I had a few false starts with editing .conf files for pipewire, but it looks like wireplumber is the way to go in Zorin 18.

Update: this wasn't behaving how I wanted it to. So that previous fix forces everything to upsample to 192000, but what I wanted to do was switch based on the quality of the source and allow the bitrate to go up to 192000.

So for WirePlumber, we remove the audio.rate command.

nano ~/.config/wireplumber/main.lua.d/51-sk02-rate.lua

Change contents to:

rule = {
  matches = {
    {
      { "node.name", "equals", "alsa_output.usb-Speed_Dragon_Fosi_Audio_SK02-01.analog-stereo" },
    },
  },
  apply_properties = {
    ["audio.format"] = "S32LE",
    ["audio.allowed-rates"] = "44100,48000,88200,96000,176400,192000",
  },
}
table.insert(alsa_monitor.rules, rule)

We also update some settings in Pipewire:

nano ~/.config/pipewire/pipewire.conf.d/10-rates.conf

Set the contents to:

context.properties = {
    default.clock.rate = 44100
    default.clock.allowed-rates = [ 44100 48000 88200 96000 176400 192000 ]
}

Restart WirePlumber and Pipewire:

systemctl --user restart wireplumber pipewire pipewire-pulse

Finally, it's not easy to get high-bitrate audio out of web browsers or PWAs, they force everything to resample to 48000. I use Tidal for my music, so you can't use the version of Tidal in Zorin Software or the PWA, you'll need to use an app called Tonearm. Now that it's behaving properly, I can see the sample rate moving up and down track to track depending on the quality of the source.

Hope this is helpful.