• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

BEGINNER QUESTION : Getting "BitPerfect" output in Linux ?

Honken

Senior Member
Joined
Mar 10, 2020
Messages
342
Likes
605
Location
Scania
Bottom line and in short, if you were paying big bucks for 24/192 or DSD stereo and multich sound files you wouldn't want pulse getting it's peanut butter sticky fingers all over the data stream. You want a bit-perfect stream directly into your DAC if for nothing else than piece of mind.


Mine is done by Audyssey XT32 + Editor app inside my Marantz AV7703 Pre/Pro feed via a HDMI line.
I see. I do not own any DSD formatted music myself - not do I know much about the format (or why it would be preferable over PCM, I'll have to admit that the math here is beyond me). As far as I am aware though, all audio within Pulse is PCM. So you are right, this would incur a conversion.

I see, so you do not do the EQ in your player then? Is it due to the MCH setup / playback you mentioned?

Thanks!
 

Sal1950

Grand Contributor
The Chicago Crusher
Forum Donor
Joined
Mar 1, 2016
Messages
14,155
Likes
16,843
Location
Central Fl
I see, so you do not do the EQ in your player then? Is it due to the MCH setup / playback you mentioned?
Yes, mostly and the large additional complications doing DRC outside a dedicated AV component.
Only guy I personally know doing things that way are @Kal Rubinson though I know there are others.
 

somebodyelse

Major Contributor
Joined
Dec 5, 2018
Messages
3,745
Likes
3,030
Are any of you guys doing any kind of room correction with your Linux setups? How are you doing this? Personally, I've ordered an UMIK-1 to measure my system & room and I was thinking of attaching an equalizer to Pulse directly. Are you guys doing it in some other way? Any tips?
As usual with linux there are many approaches - pick your poison.

A while back I experimented with BruteFIR in both Daphile and via the Volumio plugin on a Pi 3 to see how much or little CPU was needed, and whether it really caused glitches on the Pi's USB audio output - not a lot, and yes but... respectively. The Pi 4 is free of glitches, at least when I tried to provoke it. Anyway it's quite easy to add to the alsa config manually, but you'll end up resampling everything to the sample rate and bit depth you've configured BruteFIR to use. It should be possible for a player (or player plugin) to pause when there's a track change and reconfigure brutefir for the new format, but I'm not aware of any that do. These threads have a fair bit more detail, mainly covering the Volumio plugin but it's mostly applicable to other instances too. The source for the volumio plugin contains templates for the configs if you do need to add them manually, or if you need to tweak the plugin because your audio device only presents 4 output channels instead of 2.

There are other convolvers that can be used similarly, or plugged into an effects chain in Jack or Pulse. Or you could use one or more of the LADSPA filters for eq instead of a convolver. If you're using LADSPA filters via the alsa config rather than in Jack or Pulse you should look at the alsaequal plugin, especially the 'More Advanced Stuff' section about 2/3 of the way through the readme. The plugin isn't really an equalizer, but a generic way of adding a mixer interface to the controls of a LADSPA filter in the alsa config, instead of having to set static values for them.
 

Honken

Senior Member
Joined
Mar 10, 2020
Messages
342
Likes
605
Location
Scania
Yes, mostly and the large additional complications doing DRC outside a dedicated AV component.
Only guy I personally know doing things that way are @Kal Rubinson though I know there are others.
I see, thanks! I can sacrifice ease of use, but not sound quality. I am still very green when it comes to room correction and I'm not sure if the proprietary stuff is hiding some patented ideas or not.
As usual with linux there are many approaches - pick your poison.

A while back I experimented with BruteFIR in both Daphile and via the Volumio plugin on a Pi 3 to see how much or little CPU was needed, and whether it really caused glitches on the Pi's USB audio output - not a lot, and yes but... respectively. The Pi 4 is free of glitches, at least when I tried to provoke it. Anyway it's quite easy to add to the alsa config manually, but you'll end up resampling everything to the sample rate and bit depth you've configured BruteFIR to use. It should be possible for a player (or player plugin) to pause when there's a track change and reconfigure brutefir for the new format, but I'm not aware of any that do. These threads have a fair bit more detail, mainly covering the Volumio plugin but it's mostly applicable to other instances too. The source for the volumio plugin contains templates for the configs if you do need to add them manually, or if you need to tweak the plugin because your audio device only presents 4 output channels instead of 2.

There are other convolvers that can be used similarly, or plugged into an effects chain in Jack or Pulse. Or you could use one or more of the LADSPA filters for eq instead of a convolver. If you're using LADSPA filters via the alsa config rather than in Jack or Pulse you should look at the alsaequal plugin, especially the 'More Advanced Stuff' section about 2/3 of the way through the readme. The plugin isn't really an equalizer, but a generic way of adding a mixer interface to the controls of a LADSPA filter in the alsa config, instead of having to set static values for them.
Indeed, I find that to be the charm of using OSS though.

Yeah, I'm not overly worried about the RPi not keeping up, the 4 seems very... unproblematic compared to previous iterations.

So, how would a convolver differ from using an equalizer? Am I wrong in thinking that these are two different means to the same end result?

Either way, thanks for the links. It looks like I have a lot of reading to do!
 

somebodyelse

Major Contributor
Joined
Dec 5, 2018
Messages
3,745
Likes
3,030
Indeed, I find that to be the charm of using OSS though.
Me too ;-)
So, how would a convolver differ from using an equalizer? Am I wrong in thinking that these are two different means to the same end result?
I'm no expert, so I hope someone will step in if I've got this wrong. The convolver can do everything the equalizer can, but not vice versa. I'm taking 'equalizer' to mean the usual bank of fixed frequency, fixed Q filters with level controls. You can probably get equivalent using a number of parametric filters, and some all-pass filters to alter the phase. Depending on the filter chain, one or other will be computationally more expensive, but you'd probably have to experiment to find out which it is. I think the convolver is in practice trickier to alter at runtime - see the BruteFIR 'Logic Modules' section on using its cli to adjust parameters, and I'm not aware of a GUI for it.
 

Honken

Senior Member
Joined
Mar 10, 2020
Messages
342
Likes
605
Location
Scania
I'm no expert, so I hope someone will step in if I've got this wrong. The convolver can do everything the equalizer can, but not vice versa. I'm taking 'equalizer' to mean the usual bank of fixed frequency, fixed Q filters with level controls. You can probably get equivalent using a number of parametric filters, and some all-pass filters to alter the phase. Depending on the filter chain, one or other will be computationally more expensive, but you'd probably have to experiment to find out which it is. I think the convolver is in practice trickier to alter at runtime - see the BruteFIR 'Logic Modules' section on using its cli to adjust parameters, and I'm not aware of a GUI for it.
Alright, I suppose that makes sense. I'll have to take a look at BruteFIR eventually, but it seems very advanced and daunting. I've received my UMIK-1 and I'm now toying around with REW, trying to grasp it best I can. Man, it was so much easier just disabling any kind of DSP and opting for "bit perfect" out.

I came across this project and I'm currently using the rew-to-dsp shellscript that it comes with to apply the corrections from REW. It can also read a convolution file produced by REW, but I've not tried that yet. It works systemwide both with ALSA and Pulse, or as a CLI program for testing your pipeline.

Using DSP via Pulses LADSPA-module seems to consume somewhere around 10% extra CPU on my Pi 4 and it pushes the Pi out of powersaving mode. I'm not overy worried about this resource usage.
 

somebodyelse

Major Contributor
Joined
Dec 5, 2018
Messages
3,745
Likes
3,030
I came across this project and I'm currently using the rew-to-dsp shellscript that it comes with to apply the corrections from REW. It can also read a convolution file produced by REW, but I've not tried that yet. It works systemwide both with ALSA and Pulse, or as a CLI program for testing your pipeline.
Coincidentally I happened upon that project's System Wide DSP Guide yesterday. Good luck.
 

Honken

Senior Member
Joined
Mar 10, 2020
Messages
342
Likes
605
Location
Scania
Hah, what a coincidence!

Thanks, I've been toying with it quite a bit and I guess that I like it? I don't really have any knowledge on how it would compare to any other DSP solution. One boon, I guess, is that it doesn't require resampling if one is worried about that (I'm not). My only complaint is that I can't compare two different EQs from REW easily. I can however test the effect of the EQ easily (by switching the output in Pulse).

I am also a bit confused as to why there is a 20 filter limit in REW. Maybe it is just my poor acoustics that require me to have a lot of filters, but after doing a brute forced config where I simply EQ'd the lows, mids and high separately I ended up with a whopping 40 filters. I eyeballed the visualization of the filters to make sure that these wouldn't overlap. It seems to sound better than the 20 filter, whole spectrum-in-one output that REW gives me otherwise.
 

Sal1950

Grand Contributor
The Chicago Crusher
Forum Donor
Joined
Mar 1, 2016
Messages
14,155
Likes
16,843
Location
Central Fl
The problem with Cantata and gmusicbrowser is that they are not supported anymore :-(
But those are still the ones I prefer...

For Cantata, you have to edit a file.
That file can be found (on my system) as an invisible file in the "home" folder.
To see the invisible files, hit "Ctrl - H".

You should have a "local" folder that appears.
Open it.

Inside that folder, you should have a folder called "share".
Open it.

Inside that folder you should have a folder called "cantata".
Open it.

Inside that folder, you should have a folder called "mpd".
Open it.

Inside that folder, you should see a file called "mpd.conf".
Open it.

In your text editor, just make sure that you have something like this :

audio_output {
type "alsa"
name "ALSA sound card"
# Optional
device "hw:2,0"
mixer_control "PCM"
}

The only thing that you may have to change is the "device "hw:2,0".

To know what you should enter there, you will have to open a terminal.
In the terminal, type "aplay -l".
This will give a list of audio output.
Look at the output you would like to use.
For that device you should see a line like this (this is in french, but I assume you can translate easily :) )
"carte 0: PCH [HDA Intel PCH], périphérique 1: ALC1150 Digital [ALC1150 Digital]".
Note the # of "card" and the # of peripheral (in this case that would be "0,1").

Just enter that combination as a string after the "hw:X,X".

Save the file.

Start Cantata.

Done...

This looks like it is long...
It litterally takes 3 minutes top !

Regards.
Yo Mr @PenguinMusic (or anyone else) I got an issue that makes me scratch my bald head. I noticed recently after doing this edit, everything functions OK and it seems to deliver PCM files bit-perfect, but when I play a .dsf file my Marantz Pre/Pro reports receiving a 192kHz PCM file. A very strange situation as I can't figure out where the conversion is being done?
 
OP
P

PenguinMusic

Addicted to Fun and Learning
Joined
Dec 20, 2019
Messages
629
Likes
377
Yo Mr @PenguinMusic (or anyone else) I got an issue that makes me scratch my bald head. I noticed recently after doing this edit, everything functions OK and it seems to deliver PCM files bit-perfect, but when I play a .dsf file my Marantz Pre/Pro reports receiving a 192kHz PCM file. A very strange situation as I can't figure out where the conversion is being done?

Hi Sal,

No idea about ths problem as I have litterally 0 .dsf files to play :-(

So I can't say I experience the same problem... and cannot really check.

Sorry :-(
 

Sal1950

Grand Contributor
The Chicago Crusher
Forum Donor
Joined
Mar 1, 2016
Messages
14,155
Likes
16,843
Location
Central Fl
Hi Sal,

No idea about ths problem as I have litterally 0 .dsf files to play :-(

So I can't say I experience the same problem... and cannot really check.

Sorry :-(

Thanks for the response. Not a huge issue but very curious.
Cheers
 

ezra_s

Active Member
Forum Donor
Joined
Mar 23, 2020
Messages
293
Likes
327
Location
Spain
in case it hasn't been said.

The answer is "audacious",in the preferences - output select alsa, click on the options for alsa and select hw: xxx xxxx without any software conversions. Clear as the sky.
 

gfx_1

Active Member
Joined
Nov 9, 2019
Messages
138
Likes
95
Hello there, fellow Linux user checking in! I'm using MPD on a headless Raspberry 4 to play my music.
Sorry if I'm beating a dead horse here - but what is the (perceived?) problem with PulseAudio?

Pulseaudio resamples multiple sources to one bitrate. (it mixes)
With Alsa a program can hog the output. youtube video's don't play whilest listening to music.
if you open a terminal this displays the bitrate used:
$ cat /proc/asound/card*/pcm*p/sub*/hw_params

I put it in a script called bitrate:
#!/bin/sh
cat /proc/asound/card*/pcm*p/sub*/hw_params
#cat /proc/asound/card1/pcm1p/sub0/hw_params

the commented version (#) displays the active card only but you'll have to figure that one out with a bit of ls

$ cat /proc/asound/card1/pcm1p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 441
buffer_size: 8820

$ cat /proc/asound/card1/pcm1p/sub0/hw_params
access: RW_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 96000 (96000/1)
period_size: 1024
buffer_size: 8192

On a raspberry pi I use:
cat /proc/asound/card0/pcm0p/sub0/hw_params

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_digi], device 0: HifiBerry Digi HiFi wm8804-spdif-0 [HifiBerry Digi HiFi wm8804-spdif-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
 
Last edited:

MRC01

Major Contributor
Joined
Feb 5, 2019
Messages
3,476
Likes
4,094
Location
Pacific Northwest
Pulseaudio resamples multiple sources to one bitrate. (it mixes) ...
Ubuntu version 18 (but not version 16) has the latest version of Pulseaudio, which has a couple of nice things:
1. A new setting, "avoid-resampling". You can set this to True. Then Pulseaudio won't resample everything; you can listen to things at their native rate.
2. An app called PulseEffects, which can apply a bunch of various DSP - graphic EQ, parametric EQ, crossfeed, etc. This applies all sounds at the system level, not just the audio player.

When I listen to music on the PC, I organize it by directories & files, not by metadata tags. Because of this I like the VLC player. It also has built-in parametric EQ which is nice to have, especially if you don't have the latest version of Pulseaudio, so you can't use PulseEffects.

Due to Pulseaudio resampling, on Ubuntu 16 and earlier I use ALSA instead of Pulseaudio. Here's a simple bash script that will enable and disable Pulseaudio:

#!/usr/bin/env bash
# Enbable or disable pulseaudio

if [ "$1" = "-d" ]
then
sudo sed -i 's,autospawn = yes,autospawn = no,' /etc/pulse/client.conf
pulseaudio -k
elif [ "$1" = "-e" ]
then
sudo sed -i 's,autospawn = no,autospawn = yes,' /etc/pulse/client.conf
pulseaudio --start
else
echo "paudio: must specify -e (enable) or -d (disable)"
exit 1
fi


After disabling Pulseaudio, start VLC. In the VLC menu, choose Audio device, "Direct hardware device without any conversions". This will still apply any EQ you apply in VLC.
 

Sal1950

Grand Contributor
The Chicago Crusher
Forum Donor
Joined
Mar 1, 2016
Messages
14,155
Likes
16,843
Location
Central Fl
Ubuntu version 18 (but not version 16) has the latest version of Pulseaudio, which has a couple of nice things:
Thanks for posting the great info, good stuff here for many!
 
OP
P

PenguinMusic

Addicted to Fun and Learning
Joined
Dec 20, 2019
Messages
629
Likes
377
Ubuntu version 18 (but not version 16) has the latest version of Pulseaudio, which has a couple of nice things:
1. A new setting, "avoid-resampling". You can set this to True. Then Pulseaudio won't resample everything; you can listen to things at their native rate.
2. An app called PulseEffects, which can apply a bunch of various DSP - graphic EQ, parametric EQ, crossfeed, etc. This applies all sounds at the system level, not just the audio player.

When I listen to music on the PC, I organize it by directories & files, not by metadata tags. Because of this I like the VLC player. It also has built-in parametric EQ which is nice to have, especially if you don't have the latest version of Pulseaudio, so you can't use PulseEffects.

Due to Pulseaudio resampling, on Ubuntu 16 and earlier I use ALSA instead of Pulseaudio. Here's a simple bash script that will enable and disable Pulseaudio:

#!/usr/bin/env bash
# Enbable or disable pulseaudio


if [ "$1" = "-d" ]
then
sudo sed -i 's,autospawn = yes,autospawn = no,' /etc/pulse/client.conf
pulseaudio -k
elif [ "$1" = "-e" ]
then
sudo sed -i 's,autospawn = no,autospawn = yes,' /etc/pulse/client.conf
pulseaudio --start
else
echo "paudio: must specify -e (enable) or -d (disable)"
exit 1
fi


After disabling Pulseaudio, start VLC. In the VLC menu, choose Audio device, "Direct hardware device without any conversions". This will still apply any EQ you apply in VLC.


Hi,

Just tested your trick !!!
On Manjaro (arch).

AND indeed Pulse-audio now plays my 24/96 files.. at 24/96 :)

Thank you, thank you, thank you so much for this invaluable info !!!

That is saving a lot of trouble configuring ALSA.

This may be superbly helpful if I want to install something in flatpak...

Thanks a lot.

Reagrds.

Regards...
 
OP
P

PenguinMusic

Addicted to Fun and Learning
Joined
Dec 20, 2019
Messages
629
Likes
377
Hi,

Replying to myself : just tested QuoLibet in Flatpak edition...
It benefits the no resampling feature.
So a file played with QuodLibet (or any other player) outputting to PulseAudio on the "host" will play 24/96 as it should :)

And that is super good news :)
 
OP
P

PenguinMusic

Addicted to Fun and Learning
Joined
Dec 20, 2019
Messages
629
Likes
377
Hi,

Unfortunately that does not seem to allow Google Chrome to output music to 24/96 :-(
 

Sal1950

Grand Contributor
The Chicago Crusher
Forum Donor
Joined
Mar 1, 2016
Messages
14,155
Likes
16,843
Location
Central Fl
Ubuntu version 18 (but not version 16) has the latest version of Pulseaudio, which has a couple of nice things:
Couple questions, What is the build # of pulse you have installed?
1. A new setting, "avoid-resampling". You can set this to True. Then Pulseaudio won't resample everything; you can listen to things at their native rate.
Where are you accessing this setting?
TIA
 
OP
P

PenguinMusic

Addicted to Fun and Learning
Joined
Dec 20, 2019
Messages
629
Likes
377
Hi Sal,

If you're interested in that mod, it is quite simple to do :
sudo nano /etc/Pulse/daemon.conf

Scroll to end of file and add : "avoid-resampling=yes" (without the colum).

Save file (Ctrl-O) and quit nano (Ctrl-x)

Restart pulseaudio (killall pulseaudio && pulseaudio —check)...

Done... Now your 24/96 files will be played in their native bitrate with no resampling to 16/44


UNFORTUNATELY : does not allow ANY web-browser to strean in 96Khz :-(
I'm stuck at 44khz with Opera/Firefox/Chrome...
 
Top Bottom