Importing pulseaudio config to pipewire

I’m migrating from Kubuntu 21.10 to Fedora 35 KDE right now. Wanted to move my /etc/pulse/daemon.conf but found out Fedora isn’t even using pulseaudio. Could someone help me converting my config file to pipewire?

Here is my config:

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for
## more information. Default values are commented out.  Use either ; or # for
## commenting.

; daemonize = no
; fail = yes
; allow-module-loading = yes
; allow-exit = yes
; use-pid-file = yes
; system-instance = no
; local-server-type = user
; enable-shm = yes
; enable-memfd = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; lock-memory = no
cpu-limit = no

high-priority = yes
nice-level = -17

; realtime-scheduling = yes
; realtime-priority = 5

; exit-idle-time = 20
; scache-idle-time = 20

; dl-search-path = (depends on architecture)

; load-default-script-file = yes
; default-script-file = /etc/pulse/default.pa

; log-target = auto
log-level = debug
; log-meta = no
; log-time = no
; log-backtrace = 0

resample-method = soxr-vhq
avoid-resampling = false
enable-remixing = yes
; remixing-use-all-sink-channels = yes
; enable-lfe-remixing = no
; lfe-crossover-freq = 0

flat-volumes = no

; rlimit-fsize = -1
; rlimit-data = -1
; rlimit-stack = -1
; rlimit-core = -1
; rlimit-as = -1
; rlimit-rss = -1
; rlimit-nproc = -1
; rlimit-nofile = 256
; rlimit-memlock = -1
; rlimit-locks = -1
; rlimit-sigpending = -1
; rlimit-msgqueue = -1
; rlimit-nice = 31
; rlimit-rtprio = 9
; rlimit-rttime = 200000

default-sample-format = float32le
default-sample-rate = 384000
alternate-sample-rate = 384000

Pipewire has a pulsaudio plugin.

You might have to check the config file and move it to /etc/ to add your changes.

/usr/share/pipewire
$ cat pipewire-pulse.conf

# PulseAudio config file for PipeWire version "0.3.39" #
#
# Copy and edit this file in /etc/pipewire for system-wide changes
# or in ~/.config/pipewire for local changes.

context.properties = {
    ## Configure properties in the system.
    #mem.warn-mlock  = false
    #mem.allow-mlock = true
    #mem.mlock-all   = false
    #log.level       = 2
}

context.spa-libs = {
    audio.convert.* = audioconvert/libspa-audioconvert
    support.*       = support/libspa-support
}

context.modules = [
    { name = libpipewire-module-rtkit
        args = {
            #nice.level   = -11
            #rt.prio      = 88
            #rt.time.soft = 2000000
            #rt.time.hard = 2000000
        }
        flags = [ ifexists nofail ]
    }
    { name = libpipewire-module-protocol-native }
    { name = libpipewire-module-client-node }
    { name = libpipewire-module-adapter }
    { name = libpipewire-module-metadata }

    { name = libpipewire-module-protocol-pulse
        args = {
            # the addresses this server listens on
            server.address = [
                "unix:native"
                #"unix:/tmp/something"              # absolute paths may be used
                #"tcp:4713"                         # IPv4 and IPv6 on all addresses
                #"tcp:[::]:9999"                    # IPv6 on all addresses
                #"tcp:127.0.0.1:8888"               # IPv4 on a single address
            ]
            #pulse.min.req          = 256/48000     # 5ms
            #pulse.default.req      = 960/48000     # 20 milliseconds
            #pulse.min.frag         = 256/48000     # 5ms
            #pulse.default.frag     = 96000/48000   # 2 seconds
            #pulse.default.tlength  = 96000/48000   # 2 seconds
            #pulse.min.quantum      = 256/48000     # 5ms
            #pulse.default.format   = F32
            #pulse.default.position = [ FL FR ]
            # These overrides are only applied when running in a vm.
            vm.overrides = {
                pulse.min.quantum = 1024/48000      # 22ms
            }
        }
    }
]

# Extra modules can be loaded here. Setup in default.pa can be moved here
context.exec = [
    #{ path = "pactl"        args = "module-switch-on-connect" }
    #{ path = "/usr/bin/sh"  args = "~/.config/pipewire/default.pw" }
]

stream.properties = {
    #node.latency          = 1024/48000
    #node.autoconnect      = true
    #resample.quality      = 4
    #channelmix.normalize  = false
    #channelmix.mix-lfe    = false
    #channelmix.upmix      = false
    #channelmix.lfe-cutoff = 0
}

I know there is a pulseaudio plugin which converts pulseaudio calls to pipewire and I already know where the files go. But my question is how to convert the config lines and where to put them? There seems to be two configs too: pipewire.conf and pipewire-pulse.conf

The most important ones I need are those:

resample-method = soxr-vhq
avoid-resampling = false
enable-remixing = yes
default-sample-format = float32le
default-sample-rate = 384000
alternate-sample-rate = 384000

https://docs.pipewire.org/ > Documentation Pipewire

So, I have followed this guide and could learn something: Config PipeWire · Wiki · PipeWire / pipewire · GitLab

I have copied the sample config file to /etc/pipewire/pipewire.conf and changed/uncommented those two lines to:

default.clock.rate          = 384000
default.clock.allowed-rates = [ 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 ]

The allowed rates option works great in contrast to pulseaudio which caused problems. I always forced pulseaudio to use the highest sample rate and resample with highest quality. But I read this in the article:

Resampling is performed in 2 places in PipeWire.

To convert the client sample rate to the DSP sample rate of the graph (See previous topic). This will do nothing when the client has the same sample rate as the graph.
To convert the DSP sample rate to a supported device sample rate. This does nothing when the device supports the same sample rate of the DSP graph.

Did I understand correctly that there is no resampling happening if the output sample rate matches input sample rate? Pipewire sets the output sample rates to the hardware correctly if I play a audio file thanks to default.clock.allowed-rates I have checked this with watch less /proc/asound/card0/pcm0p/sub0/hw_params

Or does pipewire resample always, even to the matching sample rate output?

I also couldn’t yet find the equivalent to default-sample-format. I would like to set the format to float32le. But not sure if it’s already set by default or my card can’t support it either. But want to know where to even set this.

EDIT: So I have set higher resampling quality anyways to be on the safe side:

Copied the 3 following config files to /etc/pipewire:
client.conf OR client-rt.conf and pipewire-pulse.conf

And set/uncomment in all of them to:
resample.quality = 11

EDIT2: client-rt.conf wasn’t a good idea in conjunction with client.conf I think. Everything gone crazy so removed client-rt.conf again.