Operating systems and sound quality

In your media player you pick a song and press play.
The player gives a command to a Codec to convert the file to something the sound card can understand (PCM audio). One may wonder what this has to do with the OS at all.

Multiple streams

An OS (be it Win, OSX, Linux, etc) assumes multiple streams.
You play your audio and you want to hear a notification when a mail arrives.

Hence they have to mix and you can only mix if all streams run at the same sample rate.
For mixing, the audio is converted to, converted back to integer (otherwise your DAC can’t make sense out of it) and dithered because the quantization noise had to be removed.

 

As it assumes a fixed sample rate, you have to set this rate in the audio panel of the OS.
If you play a file with a different sample rate, the media player will resample it to the sample rate as set in the audio panel.

DSP

Mixing, sample rate conversion, volume control, etc. are all DSP (Digital Signal Processing)
The algorithm chosen, the precision of the calculation (quantization error), efficiency (latency), etc. will have its impact on the sound quality.

The XP k-mixer is famous for its disastrous sound quality. Small wonder, 16 bits integers are very efficient in calculations but the precision is to low (quantization error)
Win7 has a mixer using 32 bits float.
OSX Core audio has a 64 bit audio path.
In case of Linux there is no standard mixer. It depends on the audio stack you are using.

Drivers

Bypassing the OS audio stack is a popular tweak to avoid the conversion to float and back to integer including the dither.

Methods are:
Kernel streaming or ASIO on XP.
WASAPI/ASIO is the way on Win7.

In case of ASIO it must be supported by the hardware.
Media players using HOG mode (exclusive access), integer playback (bypassing the mixer) on OSX.

 

More about drivers.

 

You might expect differences in sound quality between the operating systems when any kind of DSP is involved as different implementations of the DSP will yield differences in sound quality.

A paper by dCs [1] demonstrates this.


An often recommended practice is to play 1 and only 1 audio stream and play it at its native sample rate to avoid any artifacts from mixing and sample rate conversion.

This works on XP.

From Vista on, all audio is mixed even if a single stream is playing.

Likewise OSX.

 

More information about configuring the audio of the OS can be found here.

References
  1. Operating systems handling of sample rate - Data Conversion Systems Ltd. (2009).
  2. Beyond bit perfect: The importance of the Player Software And MAC OS X Playback Integer Mode - Damien Plisson, Audirvana developer