Sample Rate Conversion

Like almost all operating systems, Windows is designed to handle multiple audio streams at the same time.
You are watching a video and hear a notification sound when a e-mail comes in.
This is done by mixing both audio streams.
You can only mix audio digital if both have the same sample rate.

 

All audio streams are sent to the audio engine where they are resampled (if necessary), converted to 32 bit float, mixed, dithered and converted back to integer. This happens all the time, even when only 1 stream is playing.
The sample rate and bit depth of the mixed stream are set in the audio panel. This is sent to the DAC.

 

Both dither and resampling can affect sound quality.

Dither

If one converts from float back to integer (DAC's need integer) there will always be a round off error (quantization error). As this error is correlated with the audio, dither is the trick to de-correlate it by adding some noise.

In case of a 16 bit DAC dithering is needed as artifacts at -96 dBFS can be made audible.
Today our DAC's are 24 or even 32 bit. The LSB (the least significant bit) is the one that is ditered. In case of 24 bits this is at -144 dBFS dB.
This is way below the noise floor of our gear.
Likewise a good quality Hi-Res recording contains musical info up to 20/21 bits, the rest is random noise. Makes you wonder if dithering 24 bit make sense at all.
You can safely use shared mode in case of a 24 or 32 bit DAC. Your playback chain is simply not able to resolve details at -144 dBFS not to metion -192 dBFS.

Resampling

Using shared mode, any audio stream that differs from the rate as set in the audio panel, has to be resampled.


Archimago measured the Win 10 sample rate conversion.

It requires few resources but it measures poorly.

It looks like they took some shortcuts for the sake of computational elegance at the  expense of sound quality.

Windows 10 "Audio Stack" / DirectSound Upsampling - Archimago's Musings (2015)

 

For a long time we thought the resampler to be the culprit.

Bennetng pointed out that this only happens when using full scale signals.
Anytime a signal comes close to 100%, CAudioLimiter APO kicks in and produces these artifacts.

 

Limiter

Linearity of Windows volume APIs – IAudioMeterInformation and full-scale signals - Matthew van Eerde's web log.

 

You might wonder if this is really a big problem.
Most recordings do have sufficient headroom.
Only the typical exponents of the loudness war ( strong dynamic compression and level up to 0 dBFS) might distort when resampled.

Solutions

WASAPI

A very simple one is not to use the Win audio engine.
This can be done by using WASAPI in Exclusive mode.
The output of the media player is send straight to the audio driver bypassing the mixer completely.
This is the trick to get automatic sample rate conversion.
However the properties of the stream (number of channels, bit depth and sample rate) have to match the capabilities of the audio device exactly.
If not, it is silence.
Obvious as the Win audio engine is bypassed, the bit depth/sample rate as set in the audio panel is irrelevant.
ASIO can be used as well but your audio device must support this protocol.

 

However, you can only do this if the media player allows you to choose a driver.
A lot of applications don’t offer this, they simply use the Windows Audio Stack and this shared mode by design.

Manual matching

Set the sample rate in the Audio Panel to what is common (44.1 kHz, CD quality).

If start playing hires, match the sample rate manual.
Bit of a burden if you have a mixed collection.
Likewise streaming audio services often offer a mix of 44.1 kHz - 192 kHz.

 

Besides choosing a sample rate, you have to choose a bit depth as well. Often 16 bit is advised when play Cd quality audio because 16 bit is the bit depth of CD audio. This is not a good iedea. The bit depth you set in the win audio panel is about the aritmetic precision of the data path between ypur media player and the audio device. Always max it out as this is benifial the moment you use any kind of DSP.

Pre-amp

As the resampling by Windows starts to distort only when the limiter kicks in, a very simple solution is to avoid signals close to 0 dBFS by lowering the signal by a couple of dB's.

The only thing you have to do is lowering the output of your media player.

Reducing the output to 98% should be sufficient to avoid the CAudioLimiter APO to kick in.

This requires the media player to have its own volume control.

A typical case of being bit imperfect improves the sound!

Equalizer APO

Instead of using a media player, you can do it system wide for all apps using shared mode.

Equalizer APO is indeed a equalizer but in this case you simply use its pre-amp funtion only.
Lower the volume with -4 dB and you avoid the CAudioLimiter kicking in.

DDF has more

 

References
  1. Windows 10 "Audio Stack" / DirectSound Upsampling - Archimago's Musings (2015)
  2. Windows resampling not actually that bad? - Audio Science Review
  3. Linearity of Windows volume APIs – IAudioMeterInformation and full-scale signals - Matthew van Eerde's web log
  4. Ending the Windows Audio Quality Debate - Audio Science Review (2021)