Solved Thoughts/Recommendations for setting up OSS for high quality audio processing

I was not quite happy with my sound output so, I read through the whole man sound(4) page and set up parameters accordingly in /etc/sysctl.conf.

My sound related configurations:
Code:
# Disable the automatic assignment of the default sound card.
hw.snd.default_auto=0

# Set the default sound card.
hw.snd.default_unit=0

# Set the maximum allowable sample rate.
hw.snd.feeder_rate_max=192000

# Enable the most accurate sample rate converter quality.
hw.snd.feeder_rate_quality=4

# Disable sample rate rounding for accurate sound processing (Experimental, disable if not needed)
hw.snd.feeder_rate_round=0

# Get a more detailed sndstat report.
hw.snd.verbose=2

# Enable a specific amount of vchans per device.
dev.pcm.0.play.vchans=8
dev.pcm.1.play.vchans=8
dev.pcm.8.play.vchans=8
dev.pcm.8.rec.vchans=8

# Enable a specific vchanformat per device.
dev.pcm.0.play.vchanformat=s32le:2.0
dev.pcm.1.play.vchanformat=s32le:2.0
dev.pcm.8.play.vchanformat=s32le:2.0
dev.pcm.8.rec.vchanformat=s32le:2.0

# Set a vchan format/rate selection.
dev.pcm.0.play.vchanmode=passthrough
dev.pcm.1.play.vchanmode=passthrough
dev.pcm.8.play.vchanmode=passthrough
dev.pcm.8.rec.vchanmode=passthrough

I have a few questions regarding some parameters I have set, and I have not set, but are curious whether I should set them, or not.

Before starting, I am hearing the audio through earphones in stereo format 2ch.
The audio file format is usually 24bit/96kHz flac, 24bit/48KHz flac, or 16bit/41KHz flac.
My soundcard is capable to play audio files in 32bit/192KHz, but in practice I do not know any files encoded that way.

Parameters set:
dev.pcm.0.play.vchanmode=passthrough
I am particularly interested in the "adaptive" mode as well as it seems to provide better quality, but can produce pops or clicks when the hardware DMA mode is restarted.
My question here is, if adaptive mode is used, when exactly does the DMA restarts?
Does it restart only once when the audio device is associated for streaming the audio data, since 2 channels are already used, and no new channel is going to be associated.

dev.pcm.0.play.vchanformat=s32le:2.0
Is there any other, better format I could use for headphones?

hw.snd.feeder_rate_round=0
This option is by default set to 25 to avoid large prime number divisions, but at an accuracy cost.
I have set it to 0 (disable), because I have a strong CPU and do not really want to lose sample rate precision.
Does it really matter in practical usage, or can I just leave this option at the default value without having degraded audio quality?

Parameters not set, but curious about:
dev.pcm.0.bitperfect
Does this option have any benefit on the audio quality?
I set it on once, but due to sample rate mismatch the audio quality was horrible.
However, I read that this option can be benefical to audio quality.
If so, what could I do, to set it up correctly?
 
Have you read this excellent article about this topic?

Also:
Before starting, I am hearing the audio through earphones in stereo format 2ch.
[...]
My soundcard is capable to play audio files in 32bit/192KHz, but in practice I do not know any files encoded that way.

So this is an onboard chipset? Those usually have really bad SINAD, THD+Noise and a lot of distortion and interference by design, regardless of the used DAC chipset.
Another problem is the usually *very* weak amplifier of such onboard solutions, which will run into its limits with everything remotely adiophile.

E.g.:
The front headphone port looped to back line-in (or mic), regardless of numerous different configurations I tried, only has SNR and THD+N around 70db. (bit depth and sample rate doesn't help. Doing 32bit, 192kHz usually is worse than 16bit, 48kHz)

Conclusions
Considering how bad PC implementations of audio can get, the Gigabyte Z390 Aorus actually does well. Grading on a curve, it is one of the best audio subsystems I have seen in a PC. In absolute terms though, a $99 DAC will run circles around it but audible difference may be fleeting. In other words, what is there is "good enough."
What is not good enough is the headphone output with its dismally high output impedance and inadequate output power especially with low impedance headphones. There are headphone dongles that do better than this output!

What headphones are you using exactly? Proper Headphones are usually best driven from a dedicated headphone amp or dac/amp combination. Even in the sub-50$-range there are quite good ones available that can drive most headphones except maybe some with very high impedance and/or low sensitivity.
 
Have you read this excellent article about this topic?
Yes, I have read that article, and tried the settings from there, but I got distortions so, I needed to search for different solutions.

So this is an onboard chipset? Those usually have really bad SINAD, THD+Noise and a lot of distortion and interference by design, regardless of the used DAC chipset.
Another problem is the usually *very* weak amplifier of such onboard solutions, which will run into its limits with everything remotely adiophile.
It is an onboard chipset on the aorus x670E Xtreme motherboard.

What headphones are you using exactly? Proper Headphones are usually best driven from a dedicated headphone amp or dac/amp combination. Even in the sub-50$-range there are quite good ones available that can drive most headphones except maybe some with very high impedance and/or low sensitivity.
I am using Focal Utopia 2022 rev.
Actually the audio quality of this onboard chipset is really good, and I can get the Focal Utopia headphones very loud, but I think the sound quality can get much better with a dedicated DAC/AMP.
I have searched the internet about many DAC/AMPs, but found way to many.
Is there eventually some DAC/AMP which could get everything out of this headphones?
I thought to get eventually a high end model from Chord, but I do not know if this would be overkill.
 
Yes, I have read that article, and tried the settings from there, but I got distortions so, I needed to search for different solutions.

Do you get distortions when you don't use those settings?

Is there eventually some DAC/AMP which could get everything out of this headphones?
I thought to get eventually a high end model from Chord, but I do not know if this would be overkill.

I use a Harrison 32Ci, which works great with FreeBSD. But you pay for the high end microphone preamps which you presumably don't need.
 
I am using Focal Utopia 2022 rev.
Yes, these *definitely* need a dedicated amp (and ideally also a proper DAC). According to reviews/measurements [1] those are not the most sensitive headphones and peak up to 300Ohm in impedance! This definitely requires a stable and capable amp, not some flimsy onboard toy.
Also the frequency response curve of those headphones absolutely screams for an equalizer to get it halfway close to the harman target...

Regarding DAC/AMP recommendations it basically boils down to what you want to spend - but given those headphones are listed at over 4k$, price doesn't seem to be a criteria...
That being said: DACs and AMPs are after a certain point simply transparent - i.e. there is absolute zero difference in sound as they just exactly output the signal they are being fed, regardless if one costs 5 or 10 times as much - the only exception are amps that deliberately alter the sound (e.g. tube amps). That "tipping point" where there is no more difference in the signal quality has come down quite a bit over the last few years. Where exactly that price point is, is often part of lengthy discussions, but it should be somewhere in the range of 200-400$. Above you will mainly pay for features (e.g. equalizer) and especially for a name...
I'm currently using the SMSL DL 200, but you may want to look for something that includes a (parametric) equalizer to get those focal headphones in line. The ASR forums and reviews are a great source of information, so I'd recommend you spend some time sifting through some of the threads and reviews on that topic there...


[1] https://www.audiosciencereview.com/forum/index.php?threads/focal-utopia-review-headphone.22103/
 
Do you get distortions when you don't use those settings?
No, but I get a 3% bandwith loss due to sample rate conversion.
If possible I would like to avoid that.

you may want to look for something that includes a (parametric) equalizer to get those focal headphones in line.
In the past I have used the parametric equalization feature of pipewire on void linux, but I am searching now for an equivalent for OSS on FreeBSD.
I thing of trying out this software equalizer, or do you strictly recommend one already built in into a DAC/AMP ?

That looks interesting, but there are two versions of the Focal Utopia headphone, one is from 2020 for $4k and my is from 2022 for $5k so, I need to look around in ASR forums.
They have a heavy difference in impedance. My headphone only takes 80 Ohm impedance.
 
Which specific single setting does that?
# Enable the most accurate sample rate converter quality.
hw.snd.feeder_rate_quality=4

Screw the Harman target curve :)
These are my desired EQ curve settings which I used before on Void Linux with pipewire, Could I get them eventually somehow to use with OSS. Maybe with a 3rd party plugin or something?
Or do I really need a DAC/AMP with a build in hardware equalizer?
I plan to build a DAC/AMP for these headphones though, but the question is with built in equalizer or not.
 
# Enable the most accurate sample rate converter quality.
hw.snd.feeder_rate_quality=4

And is that the setting that causes you to get distortion?

These are my desired EQ curve settings which I used before on Void Linux with pipewire, Could I get them eventually somehow to use with OSS. Maybe with a 3rd party plugin or something?
Or do I really need a DAC/AMP with a build in hardware equalizer?
I plan to build a DAC/AMP for these headphones though, but the question is with built in equalizer or not.

I listen to music through the Jamin mastering plugin, which has both graphical and parametric equalization. It requires the Jack audio demon, though, no way to insert it when using pure OSS.

I don't feel that I need an equalizer in the headphone amp. Jamin is cool and much more flexible than a hardware EQ.
 
And is that the setting that causes you to get distortion?
I do not have any audio distortions after removing dev.pcm.0.bitperfect.
The only problem I now have is the absence of an equalizer.
Does this equalizer actually works with every audio server on FreeBSD?
Kind of eager to try it out, though.

By installing jack, I would have have something like OSS <- ALSA <- JACK <- Audio file routing, right?
So, 2 audio servers sitting on top of OSS, or can I do something like OSS <- JACK Audio file routing ?
 
I do not have any audio distortions after removing dev.pcm.0.bitperfect.
The only problem I now have is the absence of an equalizer.
Does this equalizer actually works with every audio server on FreeBSD?
Kind of eager to try it out, though.

By installing jack, I would have have something like OSS <- ALSA <- JACK <- Audio file routing, right?
So, 2 audio servers sitting on top of OSS, or can I do something like OSS <- JACK Audio file routing ?

Yeah, jackd in FreeBSD sits directly on OSS. No ALSA involved.

For the equalizer above you need an audio host like a DAW.

So bitperfect caused you the distortions?
 
So bitperfect caused you the distortions?
Yes, I believe it has something to do with mismatched bit/samplerate of the file and my onboard chipset.
For using bitperfect, and avoiding distortions, probably a DAC with the option to choose variable samplerates, or samplerate presets which match the audio file would be the solution.
That way, I could avoid sample rate conversions as I guess that sample rate converters give a slightly innacurate audio output.

Yeah, jackd in FreeBSD sits directly on OSS. No ALSA involved.
That is good to hear, maybe I will give jackd a try.
Hopefully it will not end in latency problems, or audio crackling like it was with pipewire + pulse on ALSA 😅

For the equalizer above you need an audio host like a DAW.
A DAW is clearly no option for me.
But thanks to a clue from sko, I will first start and search for a DAC/AMP which complement the focal utopia 2022 headphones.
 
Yes, I believe it has something to do with mismatched bit/samplerate of the file and my onboard chipset.
For using bitperfect, and avoiding distortions, probably a DAC with the option to choose variable samplerates, or samplerate presets which match the audio file would be the solution.
That way, I could avoid sample rate conversions as I guess that sample rate converters give a slightly innacurate audio output.

If you use jackd you lock the audio playing into one sample rate, let's say 44100, at the time of demon start. If you play audio files that are 44100 then no conversion happens. If you want to play a 48000 file directly to jackd it will refuse. You must use a client that does the sample rate conversion - which most of them do of course. But the point is that it is under your control and jackd never introduces conversion behind your back.

Which client program do you use for audio file playing, anyway?
 
If you use jackd you lock the audio playing into one sample rate, let's say 44100, at the time of demon start. If you play audio files that are 44100 then no conversion happens. If you want to play a 48000 file directly to jackd it will refuse. You must use a client that does the sample rate conversion - which most of them do of course. But the point is that it is under your control and jackd never introduces conversion behind your back.

Which client program do you use for audio file playing, anyway?
I am using mpv, but it seems to play the file at a fixed sample rate.
Until now, I always thought that each sample rate needs to be converted to the native sample rate of the soundcard.
 
I am using mpv, but it seems to play the file at a fixed sample rate.
Until now, I always thought that each sample rate needs to be converted to the native sample rate of the soundcard.

If the sound card is idle (no clients) and you play something random, then your client software will set it to the desired sample rate, presumably that of the track it wants to play. If the card is already busy it can't and good client software should convert.

With jackd the situation is that you pick a sample rate at demon startup. Everything else needs to be converted.

I am sure than mpv will do conversion if required. I don't use it, so I don't know offhand whether jackd support is compiled in by default on FreeBSD.
 
If the sound card is idle (no clients) and you play something random, then your client software will set it to the desired sample rate, presumably that of the track it wants to play. If the card is already busy it can't and good client software should convert.

With jackd the situation is that you pick a sample rate at demon startup. Everything else needs to be converted.

I am sure than mpv will do conversion if required. I don't use it, so I don't know offhand whether jackd support is compiled in by default on FreeBSD.
Checked right now, and indeed it does sample rate conversion.
No, jackd is not compiled into mpv by default, but I use poudriere to built every single port so, it will not be a problem to get support for.
 
Distortions are due to mismatch between resolution you ask card to process and actual one your music file is. The best audio quality is when you use bitperfect mode - thus feeding your sound card directly bypassing any mixers, equalizer and whatever processings are used by default. To use it, you need to remove any rate quality, you need to disable all vchans completely ( set to 0 ), set your sound to use bitperfect. This is my settings for on-board realtek acl258 on thinkpad t480:
Code:
# sound setup/bitperfect
hw.snd.default_auto=0
hw.snd.default_unit=0
hw.snd.maxautovchans=0
dev.pcm.0.play.vchans=0
dev.pcm.0.bitperfect=1
hw.snd.latency=0
# dont autoreset vol to default
hw.snd.vpc_autoreset=0
kern.timecounter.alloweddeviation=0
Suit to your card number
 
Distortions are due to mismatch between resolution you ask card to process and actual one your music file is. The best audio quality is when you use bitperfect mode - thus feeding your sound card directly bypassing any mixers, equalizer and whatever processings are used by default. To use it, you need to remove any rate quality, you need to disable all vchans completely ( set to 0 ), set your sound to use bitperfect. This is my settings for on-board realtek acl258 on thinkpad t480:
# sound setup/bitperfect hw.snd.default_auto=0 hw.snd.default_unit=0 hw.snd.maxautovchans=0 dev.pcm.0.play.vchans=0 dev.pcm.0.bitperfect=1 hw.snd.latency=0 # dont autoreset vol to default hw.snd.vpc_autoreset=0 kern.timecounter.alloweddeviation=0Suit to your card number
Many Thanks :D
I really appreciate it.
Tried out different flacs now, and they finally sound so very detailful like I heard them back then with pipewire + pulse on linux, but without any crackling.
Any equalizing is definitely not needed anymore. :)

The thread is definitely solved.
 
Many Thanks :D
I really appreciate it.
Tried out different flacs now, and they finally sound so very detailful like I heard them back then with pipewire + pulse on linux, but without any crackling.
Any equalizing is definitely not needed anymore. :)

The thread is definitely solved.
What sound card it is, by the way? Because, not every sound card do work in bitperfect mode and it is kind of a guess game. It is not due to FreeBSD, because it does what is should in bitperfect mode - feeding the card directly with your music ( sounds silly ) but due to many manufactureres doing some undocumented things with their cards ( especially USB cards ).
 
Linux shouldn't crackle either, though. But I didn't try the pulseaudio interface to pipewire.
ALSA did not crackle at all, but it took some effort to get it that way.

What sound card it is, by the way? Because, not every sound card do work in bitperfect mode and it is kind of a guess game. It is not due to FreeBSD, because it does what is should in bitperfect mode - feeding the card directly with your music ( sounds silly ) but due to many manufactureres doing some undocumented things with their cards ( especially USB cards ).
My soundcard is a ESS ES9118 DAC chip (Realtek® ALC1220-VB) on a Aorus X670E Xtreme mainboard.
 
thx. so if you do
# sysctl hw.snd.verbose=2 and the check
cat /dev/sndstat
you should get BITPERFECT in output. Then you are fine!

sysctl hw.snd.verbose=2 is already in my /etc/sysctl.conf.
If I issue cat /dev/sndstat | grep BITPERFECT I get as output:
Code:
snddev flags=0x3e7<SIMPLEX,AUTOVCHAN,SOFTPCMVOL,BUSY,MPSAFE,REGISTERED,BITPERFECT,VPC>
        channel flags=0x20004000<VCHAN_PASSTHROUGH,BITPERFECT>
    snddev flags=0x3e7<SIMPLEX,AUTOVCHAN,SOFTPCMVOL,BUSY,MPSAFE,REGISTERED,BITPERFECT,VPC>
    snddev flags=0x3e2<AUTOVCHAN,BUSY,MPSAFE,REGISTERED,BITPERFECT,VPC>

Bitperfect only seems to work on my chipset with rates like 44100, 48000, and 96000 without underruns, but that is fine, as I do not intend with the headphones to watch streams or hear music through youtube.

Monitor sound and headphone sound now works fine, and I still have some questions left.

man sound mentions something about hw.snd.latency and hw.snd.latency_profile.
Are they both related?
For example, hw.snd.latency is set to 0 so, I get the lowest possible buffering latency.

hw.snd.latency_profile is not set by me.
It offers buffering latency conversion tables.
Its default value is 1 (sane latency profile), with sane values in its table I assume.

Does it mean that if hw.snd.latency is set to 0, hw.snd.latency_profile will provide me the lowest possible buffering latency value specified in its sane table?
 
Latency is completely irrelevant to "quality" and the defaults are fine unless you are playing music professionally. Listening should not require any adjustment unless you hear stuttering (in which case the value should be increased).
 
Back
Top