Page 1 of 1

Sample Rate in Pipewire

Posted: Wed Apr 24, 2024 4:19 pm
by Largos

This is an attempt to take info from here and explain the pertinent bits to here.

Out of the box the Sample Rate used in pipewire is 48k. Any other sample rates will be transcoded by pipewire to 48k. JACK applications generally don't specify their own sample rate, so they will use whatever the default is, if no other sample rate is allowed (more on that in a bit). To change the default sample rate, you can create a short config file in the folder

Code: Select all

~/.config/pipewire/pipewire.conf.d/

For the example, this file is called

Code: Select all

10-rates.conf

Can change the "rates" text to what you want but the 10- prefix is necessary. If you wanted to change the default sample to 44100, this file would contain the text

Code: Select all

context.properties = {
  default.clock.rate = 44100
}

Save it and then restart pipewire with the systemd command to enact the change.

Code: Select all

systemctl --user restart pipewire

However, there is a way to allow different native (for want of a better term) sample rates,which you change dynamically to avoid transcoding.

Using the same file as above with this text

Code: Select all

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

This allows these rates to be the set rate, provided they are the initial connection. So for example: Program A starts first and is set at 96k, the device will connect at that and when Program B starts at 48k, that will be transcoded to 96k. Applications that don't specify sample rate will still follow the default or if there is a Program already connected or will transcode if necessary.

Though you can prefix an application with a command like

Code: Select all

PIPEWIRE_LATENCY=256/48000 jack_simple_client

to specify buffer/sample rate.