Bit perfect playback on Linux (Pipewire)

Jun 26, 2024 at 8:48 AM Thread Starter Post #1 of 17

Vamp898

Headphoneus Supremus
Joined
Mar 5, 2020
Posts
4,273
Likes
5,198
Location
Japan
For anyone using Linux not knowing if and how to setup bit perfect playback, here is a very short and cut to the point guide.

First of all, find your soundcard

Code:
[vamp898@VampBook ~]$ cat /proc/asound/cards
 0 [Pro            ]: USB-Audio - MOONDROP Dawn Pro
                      MOONDROP MOONDROP Dawn Pro at usb-0000:01:00.0-3, high speed
 1 [Generic        ]: HDA-Intel - HD-Audio Generic
                      HD-Audio Generic at 0xfcb80000 irq 85
 2 [S68c           ]: USB-Audio - Studio 68c
                      PreSonus Studio 68c at usb-0000:07:00.3-1, high speed

In my case, it is card 0, the Dawn Pro.

Next step, check what bitrates this sound card supports (use the number from above)

Code:
[vamp898@VampBook ~]$ cat /proc/asound/card0/stream0 | grep Rates | sort -u
    Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000

And now just tell Pipewire to use these bitrates and to use highest quality when doing resampling

Code:
vamp898@VampBook ~ $ cat .config/pipewire/pipewire.conf.d/hires.conf  
context.properties = {
    default.clock.allowed-rates = [ 44100 48000 88200 96000 176400 192000 352800 384000 ]
}
stream.properties = {
    resample.quality = 14
}

Don't forget to restart pipewire and check if its working with pw-top

1719406417096.png
 
Last edited:
Jun 26, 2024 at 11:09 AM Post #2 of 17
For anyone using Linux not knowing if and how to setup bit perfect playback, here is a very short and cut to the point guide.

First of all, find your soundcard

Code:
[vamp898@VampBook ~]$ cat /proc/asound/cards
 0 [Pro            ]: USB-Audio - MOONDROP Dawn Pro
                      MOONDROP MOONDROP Dawn Pro at usb-0000:01:00.0-3, high speed
 1 [Generic        ]: HDA-Intel - HD-Audio Generic
                      HD-Audio Generic at 0xfcb80000 irq 85
 2 [S68c           ]: USB-Audio - Studio 68c
                      PreSonus Studio 68c at usb-0000:07:00.3-1, high speed

In my case, it is card 0, the Dawn Pro.

Next step, check what bitrates this sound card supports (use the number from above)

Code:
[vamp898@VampBook ~]$ cat /proc/asound/card0/stream0 | grep Rates | sort -u
    Rates: 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000

And now just tell Pipewire to use these bitrates (create this file as root)

Code:
[root@VampBook vamp898]# cat /etc/pipewire/pipewire.conf.d/hires.conf
context.properties = {
    default.clock.allowed-rates = [ 44100 48000 88200 96000 176400 192000 352800 384000 ]
}

Restart Pipewire
Code:
systemctl --user restart pipewire

And you're done =)

Bonus: you can tell Pipewire with which quality he should do down-/upsamples for unsupported bit-rates. If you want the highest quality, use this config

Code:
[root@VampBook vamp898]# cat /etc/pipewire/client.conf.d/hires.conf
stream.properties = {
    resample.quality = 14
}

To check if its working, just use pw-top

1719406417096.png
Ooh!! Something new to try. I will reformat my NUC and install Linux.
 
Feb 17, 2025 at 11:27 AM Post #3 of 17
I upgraded to guide to not need any root-access =) i think thats more user-friendly
 
Feb 21, 2025 at 4:29 PM Post #4 of 17
Thanks for the guide i think many beginners appreciate it.... imo you cant beat pipewire sound quality wise (windows simply sounds subpar)

just for completeness:

default.clock.allowed-rates = [ 192000 ]
will force everything upsampled to 192k (if you dont wanna go bitperfect, imo high quality resampling with pipewire algorithm on max setting is quite beneficial too, atleast worth a try)

stream properties section inside client.config and client-rt.config
stream.properties = {
#node.latency = 1024/48000
#node.autoconnect = true
#resample.quality = 4
resample.quality = 14
#channelmix.normalize = false
#channelmix.mix-lfe = true
#channelmix.upmix = true
#channelmix.upmix-method = psd # none, simple
#channelmix.lfe-cutoff = 150
#channelmix.fc-cutoff = 12000
#channelmix.rear-delay = 12.0
#channelmix.stereo-widen = 0.0
#channelmix.hilbert-taps = 0
#dither.noise = 0
dither.noise = 1
#dither.method = none
dither.method = shaped5
}

Notice the used dither section:
dither.noise = 1
dither.method = shaped5
i just noticed looking it up in the pipewire wiki there is a new dither.method which wasnt in my config file


there is also this section inside pipewire.conf and pipewire-pulse.conf:
# Uses realtime scheduling to boost the audio thread priorities. This uses
# RTKit if the user doesn't have permission to use regular realtime
# scheduling.
{ name = libpipewire-module-rt
args = {
#nice.level = -11
#rt.prio = 88
#rt.time.soft = -1
#rt.time.hard = -1
nice.level = -20
rt.prio = 88
rt.time.soft = -1
rt.time.hard = -1
}
you can see the default and adjusted values, got zero problems with this and liqourix kernel, literally zero xruns inside carla/pipwire-jack after hours


----- double post

Also one major flaw of the bit-perfect scheme in pipewire to keep in mind:

if you use this generic line:
default.clock.allowed-rates = [ 44100 48000 88200 96000 176400 192000 352800 384000 ]

then actually the first music stream played will enforce the "bitperfect" samplerate.... every other stream which comes after that will be resampled to the first samplerate.....

now if you start for example a youtube video first or its still in the background and the stream stays open at 48khz then everything (even your 44,1khz "bitperfect" music) will get resampled to 48khz

if you ensure your music stream is the first (and/or only open) then you are fine, otherwise NOT!
 
Last edited:
Feb 22, 2025 at 1:43 PM Post #5 of 17
Thanks for the guide i think many beginners appreciate it.... imo you cant beat pipewire sound quality wise (windows simply sounds subpar)

just for completeness:


will force everything upsampled to 192k (if you dont wanna go bitperfect, imo high quality resampling with pipewire algorithm on max setting is quite beneficial too, atleast worth a try)

stream properties section inside client.config and client-rt.config


Notice the used dither section:

i just noticed looking it up in the pipewire wiki there is a new dither.method which wasnt in my config file


there is also this section inside pipewire.conf and pipewire-pulse.conf:

you can see the default and adjusted values, got zero problems with this and liqourix kernel, literally zero xruns inside carla/pipwire-jack after hours


----- double post

Also one major flaw of the bit-perfect scheme in pipewire to keep in mind:

if you use this generic line:


then actually the first music stream played will enforce the "bitperfect" samplerate.... every other stream which comes after that will be resampled to the first samplerate.....

now if you start for example a youtube video first or its still in the background and the stream stays open at 48khz then everything (even your 44,1khz "bitperfect" music) will get resampled to 48khz

if you ensure your music stream is the first (and/or only open) then you are fine, otherwise NOT!
Yeah, I know, but pausing the stream usually helps^^

But if I listen to music actively, there are no other streams running anyway. And as you said, at highest quality settings, the resampling is excellent.
 
Feb 22, 2025 at 2:12 PM Post #6 of 17
I appreciate how much simpler/smaller your `hires.conf` is than whatever I used to run in `~/.config/pipewire/*` (which spanned several config files including some that required specifying a sound card, last time I bothered with bit-perfect audio). Your 6 lines or so got my DAC changing bitrates again for the first time in a year or two since I last bothered configuring this stuff :)
 
Feb 22, 2025 at 3:39 PM Post #7 of 17
Yeah, I know, but pausing the stream usually helps^^

But if I listen to music actively, there are no other streams running anyway. And as you said, at highest quality settings, the resampling is excellent.
i checked this 1-2 years ago so could be possible pipewire is now handling it differently, back then even paused open streams kept the samplerate from changing

I appreciate how much simpler/smaller your `hires.conf` is than whatever I used to run in `~/.config/pipewire/*` (which spanned several config files including some that required specifying a sound card, last time I bothered with bit-perfect audio). Your 6 lines or so got my DAC changing bitrates again for the first time in a year or two since I last bothered configuring this stuff :)
indeed! doing it `~/.config/pipewire/*` is the standard way where you copy the default conf files into your home folder and edit them, still have that but as the dither example shows i might need to refresh things at some point
 
Feb 24, 2025 at 3:37 AM Post #8 of 17
I appreciate how much simpler/smaller your `hires.conf` is than whatever I used to run in `~/.config/pipewire/*` (which spanned several config files including some that required specifying a sound card, last time I bothered with bit-perfect audio). Your 6 lines or so got my DAC changing bitrates again for the first time in a year or two since I last bothered configuring this stuff :)
I am always happy when i can help =)

Sometimes, less is more than more^^ this also counts for the applications less and more ;)
 
Feb 24, 2025 at 6:04 AM Post #9 of 17
Feb 24, 2025 at 8:13 AM Post #10 of 17
@Vamp898

Do you use any kind of EQ?

in theory there is a parametric eq right inside pipewire: https://docs.pipewire.org/page_module_parametric_equalizer.html

two other options would be EasyEffects or Carla running plugins (which i use, tho i havent figured out yet how to run Windows/VST plugins)

This is the EQ im using inside Carla, but also EasyEffects implements this exact plugin, just with a way worse GUI
https://lsp-plug.in/?page=manuals&section=para_equalizer_x16_stereo
I played around with an Equalizer that supports AutoEQ/Wavelet, don't remember the name. I think it had an Qt interface, but not 100% sure. But only to test my Flat/Accurate Target.

I use flat/reference studio monitor IEM, and even though some buy them to have a base for EQing, i bought them to sound exactly how they do, transparent/reference like^^

so i have no intention to use any EQ currently as the target is also pretty much finished in the limitations of coupler conducted IEM measurements.
 
Feb 24, 2025 at 8:23 AM Post #11 of 17
I played around with an Equalizer that supports AutoEQ/Wavelet, don't remember the name. I think it had an Qt interface, but not 100% sure. But only to test my Flat/Accurate Target.

I use flat/reference studio monitor IEM, and even though some buy them to have a base for EQing, i bought them to sound exactly how they do, transparent/reference like^^

so i have no intention to use any EQ currently as the target is also pretty much finished in the limitations of coupler conducted IEM measurements.

i wanted to look into some headphone/speaker simulation or binaural/crossfeed plugins, which might be interesting to you too, but that requires carla running plugins

its your opinion, but imo its hard to believe that IEMS will achieve the "perfect reference sound" (specially for different ear canals etc) and specially if you got different iems/headphones/speakers (switching profiles inside the eq plugin is rather easy)
 
Feb 24, 2025 at 10:17 AM Post #12 of 17
i wanted to look into some headphone/speaker simulation or binaural/crossfeed plugins, which might be interesting to you too, but that requires carla running plugins

its your opinion, but imo its hard to believe that IEMS will achieve the "perfect reference sound" (specially for different ear canals etc) and specially if you got different iems/headphones/speakers (switching profiles inside the eq plugin is rather easy)
There are several IEM used in Sound Studios to Record/Mix/Master Music.

In Japan one of the most common is the FitEar MH334 Studio Reference that was tuned by famous Mixing/Mastering Engineers. A lot of artists inside Japan use that one.

I do not have that much knowledge outside Japan, but know that some studios in Germany (because a few in Japan use them too) use Vision Ears which are also common. Especially the VE3.2 and VE7 seems the be a favourite (both are Made in Germany too what is kinda cool as i am originally from Germany, but as i choosen Japan as my country to live in, i have to use FitEar^^)

Google told me, that Ultiamte Ears has success with the UE RR (Reference Remastered) in the US and also Westone with the Mach 60.

Of course, non of these is 100% perfect, but they actually work more reliable than speakers where a simple shift in your sitting position already affects the sound and you constantly have to re-calibrate them when you change the interior of the Studio and so on. At least with the people i worked with, the variation in ear canal is a much smaller problem than the constant re-calibration of speakers that sound different in every single room.

Speakers are, of course, still used, but i personally had no case so far where things mixed/mastered on the IEM sounded wrong/off on the speakers. You can transfer Masters back and forth and everything sounds as it should. imho its much more reliable than speakers where you wonder, why the bass suddnely sounds different and its because there is a karton in the back of the room someone forgot.

Surprisingly this works better with IEM than with Headphones. The only Headphone i found so far that gets close to that experience have been the HD 490 Pro, but they are not as good as my FitEar
 
Feb 24, 2025 at 10:58 AM Post #13 of 17
There are several IEM used in Sound Studios to Record/Mix/Master Music.
imo there is a reason why usually (if possible) a mix goes atleast once trough some big studio monitors (with dialed in room accoustics), specially in the later stages (mixing/mastering)

tho that doesnt mean a lot of work cant be done with other means, specially if you know your equipment and how it translates

its all about what works in the end i guess :)

tho, i still find it interesting to simulate speakers or the speaker response on headphones (beside EQ), havent digged deep here beside some crossfade (which i prefer), but i thought i would ask, as i believe you cant do better than pipewire/carla for such a route
 
Feb 25, 2025 at 2:49 AM Post #14 of 17
Because i got asked this question, yes, this works with all applications, including BluRay and VM and so on. Here an sample from an Hi-Res Audio BluRay, no issues.

Screenshot_20250225_164415.pngScreenshot_20250225_164429.png

As long the application which is used for playback doesn't do any resampling, everything should be bit-perfect. Everything i was able to test did work
 
Last edited:
Feb 25, 2025 at 2:21 PM Post #15 of 17
As long the application which is used for playback doesn't do any resampling
oh, good that you mention it..... avoid chromium based browser, they are resampling everything as far i know/last time i checked around half year ago

you probably wont notice it under windows, but i guess/think the same thing happens there as under linux because to me firefox always sounded better than chromium, either on windows or linux, definitely more noticable with lossless but i thought even youtube sounded a smitch better
 
Last edited:

Users who are viewing this thread

Back
Top