Sample Rate Conversion

Operating systems are designed with multiple audio streams in mind.
You are watching a video but you like to hear an email notifications as well.
This can only be achieved by mixing both.
Mixing can only be done if both streams run at the same sample rate. Beside, our DAC can’t run at different clock speeds at the same time anyway.

Resampling is also needed if the audio exceeds the capacity of your DAC e.g. you have a 24 bit / 192 kHz recording but your hardware is limited to 24 bits / 96 kHz.

 

You set a fixed sample rate and bit depth in the audio panel of the OS.
All streams will be resampled to this rate if needed.

Bit depth is set to the max your DAC supports.
A reason to do so is the dither.
Mixing is done by converting the audio to float, mix, dither and convert back to integer as this is the format a DAC expect.

Dither is adding noise to the LSB. In case of 16 bits, this is audible on most gear.
Set the bit depth to 24 (or 32 on modern DAC’s) the dither is now way below the noise floor of any playback chain. Obvious, maxing out the bit depth has no audible consequences.

Sound quality

Sample rate conversion shouldn't affect sound quality.
Writing a good SRC is not trivial.
Iin the past it was notorious for generating all kind of artifacts.
Today it is often done with excellent transparency.

 

Windows XP
Famous is the XP K-mixer. You can find tons of complains about it on the internet.

As Microsoft dropped support for XP, this has become a moot point.

 

Benchmark Media provides an example of the impact of sample rate conversion in OSX 10.4.6

 

A 16-bit 10k sine wave played through iTunes on OSX 10.4.6, without any sample-rate conversion.

 

A 16-bit 10k sine wave played through iTunes on OSX 10.4.6,

with sample-rate conversion from 48 kHz to 44.1 kHz.

 

The distortion seen in this graph is solely caused by sample-rate converting from 48 kHz to 44.1 kHz. As seen in the graph, the signal-to-noise ratio went from 130 dB to less then 80 dB!

Apples own K-mixer.

 

This information is from 2006, today Apple does a much better job.

 

Apple Mac OS X ("Yosemite") Software Audio Upsampling - Archimago's Musings .

 

 

dCS measured the up sampling in Vista from 44 to 96.

The dark line is the original 16/44.1 signal.

Obvious Vista SRC generates artifacts.

I must admit I do think the artifacts way to high.
So high, I wonder if dCs has measured it correctly.

 

Archimago measured the Win 10 sample rate conversion

It will do so requiring few resources.
That’s nice as even on a low powered computer it will work but unfortunately it measures poorly.

 

MEASUREMENTS: Windows 10 "Audio Stack" / DirectSound Upsampling - Archimago's Musings

 

After the dreaded K-mixer in XP, Microsoft did it again!
Another crappy re-sampler.

 

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

This means the re-sampler is OK after all.
All you have to do when using DS is to avoid signals close to 0 dBFS.
Using just a slight attenuation before the signal is send to the Win audio stack will do.
See Windows Sample Rate Conversion for solutions.

Solutions

Both Win7 and OSX have a preference panel where you can set the sample rate.
If the source differs from this rate, it will be re-sampled.

If you don’t want to have this, you need to configure the PC for automatic sample rate switching.
You might also want a single stream as there is nothing as annoying as listening to a string quartet and having all of a sudden a email notification at full blast over the stereo.

Testing

A first an obvious one it to fool around a little with the SRC of your operating system.
Play Redbook audio (44.1 kHz) and try a couple of settings like 48, 88 and 96 (if your hard ware supports this).
Download a hi-res track e.g. 24/96 or 24/176 and try various down sampling rates.

If you don’t hear a difference, stop bothering.

Fixed

If your collection is 44.1 only (CD, MP3) you might simply set the OS to 44.1 kHz.

Bypassing the OS

All operating systems expect you to use DSP (like volume control) and play multiple streams.
Hence all audio is converted to float and fed into a mixer.

As our DACs most of the time only understands 16 or 24 bit integers, the audio is dithered and converted to 24 (or 16 if you have an old DAC).

 

You can avoid this by bypassing the OS audio.
If your hardware supports ASIO, you can use this driver.
Windows also offers WASAPI.
On a Mac look for media player offering integer mode.

If you bypass the OS audio, you get automatic sample rate switching as well.

Of course this only works as long as the hardware supports the formats you provide.

Playing all your audio at its native sample rate is probably the best solution.

Software or hardware

A lot of DACs do up-sampling. Often everything is up-sampled to e.g. 24/192.
This is done by a DSP-chip, a microprocessor.
Compared with a PC they are down in power and precision. A PC can do everything in 64 bit float or even 128. DSP chips in general are down on precision.
An option is to let the PC do the SRC; you defeat the SRC of the DSP chip.

 

In practice it is often very hard to find out what sample rate is used for the actual conversion.
The sense lights of your DAC tells you the rate of the incoming stream.
Specs like 32bit 768kHz PCM DSD512 tells you something about the maximum capacity of the receiver (probably a Xmos USB receiver) , not to be mistaken for the actual sample rate of the conversion (as a lot of people think).


Often DACs run at a rate not equivalent to any standard PCM rate.
This is called asynchronous sample rate conversion.
It is a very effective method to get rid of input jitter.
Inherent to asynchronous sample rate conversion is that there is no relation between the clockspeed of the DAC and the incoming audio stream.

An example is the Benchmark DAC 1, internally it runs at 110 kHz regardless of the incoming stream.
In this scenario it is best to send the audio stream unaltered (bit perfect) to the DAC. Things won’t improve if the audio is resampled twice, first by the PC and then by the ASR of the DAC.

 

A bit more about resampling.

 

References
  1. Windows resampling not actually that bad? - Audio Science Review (2019)
  2. Linearity of Windows volume APIs – IAudioMeterInformation and full-scale signals - Matthew van Eerde (2011)
  3. Asynchronous upsampling to 110 kHz - John Siau (2010)