My favorites | Sign in
Logo
             
Search
for
Updated Jan 11, 2009 by dogber1
Labels: Featured
Bitperfect  
"Bitperfect" / "bit-exact" explained

What is "bitperfect", and what do I have to do for bitperfect playback?

An important measure for the quality of a soundcard's SPDIF port is the capability of so called "bitperfect playback" - this term coins the ability to directly transmit sound data through its SPDIF port to a receiver (e.g. a regular home theater amplifier, a custom built DAC, etc.) without having any loss or degradation in the process. An obvious way of testing this is to play some wave file while recording the output signal at the SPDIF port with another soundcard: after synchronization of the played and recorded sound files, a bit by bit comparison of both files should result in no differences if both soundcards are bitperfect.

There are easier ways to test this capability, they require however a receiver capable of decoding ac3 or dts. The basic assumption behind this test is that any kind of audio processing usually alters the ac3/dts frames in a way that corrupts them. The receiver fails to identify damaged ac3/dts frames and plays them like regular PCM audio which make them sound like white noise. By playing ac3 or dts audio embedded into a regular wave file (samples are available here), a playback chain (player software => kmixer/audio service => driver) can be tested for whether or not audio processing takes place: if the chain is bitperfect, the receiver decodes the DTS, and if the chain isn't, the receiver plays white noise.

Most consumer grade soundcards aren't bitperfect by design: some sound hardware may be limited to only one sample rate to the effect that sound processing is mandatory (sample rate conversion in this case), in other soundcards' drivers there are annoying "features" which can't be fully disabled (e.g. karaoke, fake 3D sound, "crystalizer" and alike). The latter applies to the C-Media based soundcards: while the hardware is fully capable of bitperfect playback at a multitude of sample rates, all versions of the official driver process the sound. Some versions even cripple the sample size of the sound data from regular 16 bit down to 14 bit which results in a hefty loss of dynamic range (roughly estimated from 96dB/16 bit to 84dB/14 bit).

In the professional grade market, customers expect their soundcards to be bitperfect for obvious reasons, and the drivers are specifically engineered for this. These soundcards often come laden with other features which are pretty much useless in a regular home theater/HiFi environment (e.g. multitrack recording). Moreover, they're manufactured in much smaller volume than consumer grade soundcards, hence their pricetag is usually tenfold or even more of what a regular consumer soundcard costs.

So in essence, in the past there have been only two options for the audiophile user: either accept the deterioration of sound quality induced by the driver's processing, or bite the bullet and buy an expensive professional grade soundcard. Not anymore: after reading the specs of a C-Media chip, I decided to write my own driver from scratch which completely avoids processing. It is compatible to C-Media based soundcards which are widely available for a mere 20 US$/€. The result is a slim and sleek driver which runs on all major Windows operating systems. It supports bitperfect playback for 16 bit sound streams at sample rates of 44.1kHz, 48kHz, 88.2kHz and 96kHz - this effectively covers almost all music on CDs and subsequent formats as well as audio from DVDs on sale today.

On the software side, there are some more obstacles: in order to play multiple sounds simultaneously, a so called "kmixer" / "kernel audio mixer" (XP, 2000) respectively "audio service" (Vista) which is part of the sound subsystem of Windows mixes them together and adjusts the volume of the resulting stream. Contrary to popular belief, the kmixer of Windows 2000 and XP doesn't modify the sound and is thus bitperfect if these four conditions are met:

  1. The PCM/wave volume slider of the mixer (sndvol32.exe) must be set at its maximum. Some start-up applications modify the volume slider (e.g. hardware monitoring tools from Asus).
  2. The player must be compiled for the same architecture that the OS was compiled for - e.g. 32 bit player on a 32 bit OS, 64 bit player on a 64 bit OS. This is the case for the vast majority of installations because the 64 bit version of Windows XP isn't very commonly used.
  3. Applications other than the player mustn't play sounds, otherwise the two output streams will be potentially sample rate converted and mixed.
  4. Applications which are using the soundcard for recording have to use the same sample rate as concurrently running applications which are playing sounds - the soundcard has only one clock generator and hence this limitation arises.

Most parts of the sound subsystem of Windows XP/2000 including the kmixer run in the privileged kernel mode, and this poses a security threat because most drivers are badly written with regard to security. The sound subsystem has thus been completely rewritten for Vista so that most parts, including the audio service which provides the functionality of the kmixer, runs in user mode. Also, they've changed the internal format which is used for audio processing from 16 bit integer to 32 bit float. A sample size of 16 bit is commonly used on most media, but it's difficult to handle when it comes to audio processing. The new 32 bit float audio engine of Vista processes multiple audio streams a lot better with regard to audio quality than the old 16 bit kmixer of XP/2k. Unfortunately though, Vista's reimplementation apparently doesn't disable the sound processing when it isn't needed to the effect that the audio service is not bitperfect anymore - audio processing happens on all the sound data when the application uses only standard interfaces like DirectSound/MME (with the exception of DD/dts passthrough).

For some users, it may be therefore necessary to bypass the kmixer/audio service alltogether for bitperfect playback. This can be done in either of these two ways:

  1. Kernel streaming - this interface has been implemented to 2000/XP/Vista in response to Steinberg's ASIO. Applications which use this interface instead of DirectX/MME bypass the kmixer. In Vista, the kernel streaming interface has been marked "deprecated", and it doesn't work with WaveRT versions of the driver, but it can be used with non-WaveRT versions. There are output plugins for all the popular players, namely WinAMP and foobar2000.
  2. WASAPI - a new interface which appeared first in Vista. Applications which utilize its "exclusive mode" have bitperfect access to the soundcard's driver. This works with both the WaveRT and the non-WaveRT version. Recently, a plugin for foobar2000 has been released: http://www.foobar2000.org/components/

If you have any comments or questions about the above topics, feel free to drop me an email or use the comment system below.


Comment by rsrypma, Mar 22, 2008

Dogbert, I have been trying to find that chart you had created showing the differences between running XP, Vista (WDM drivers), and Vista (WaveRT drivers) in terms of whether they can take advantage of ks/asio or not.

Could you please provide a link to that page? Thank you!

Comment by dogber1, Mar 23, 2008

When I moved the site to google code, I've decided to remove the page because it often led to confusion more than clarification, and minor things on it were incorrect.

Comment by Jace.deHodossy, Jan 21, 2009

I use xmplay with asio4all under Windows 7. Is this couple bitperfect? Does asio4all bypass the audio service (let's say that it's Vista like). THANKS!

Comment by dogber1, Jan 21, 2009

From the first glance, yes. ASIO4All is a ASIO to KS wrapper, and KS overrides the audio service. In addition, you could try the WaveRT version of the driver and the WASAPI output plugin of XMPlay - please note you have to reduce the size of the plugin's buffer before it can be used.

Comment by Jace.deHodossy, Jan 22, 2009

I'll give it a try. Thanks again for your help!

Comment by bwaslo, Mar 25, 2009

dogber1,

Can you give any tips on how to program for the WASAPI "Exclusive Mode"? Can it be done using non-MS tools, such as Win32 Delphi, or must it be done using .Net or the like.? Is there documentation anywhere about writing Wxclusive Mode apps?

Comment by dogber1, Mar 25, 2009

The MSDN has pretty comprehensive documentation. A code sample is available here. I don't know whether there are any headers for Delphi - presumably there aren't any so you have to generate them yourself.

Comment by beast.dk, Apr 12, 2009

Need to know if the output is still bitperfect if I use the kmixer to adjust volume (wave slider) with your driver on XP/Vista/7 - as far as I understand it will not be bitperfect unless the volume is set to max?

I need to use the driver together with a home made DAC and a power amplifier connected directly to the DAC. E.g. I have to adjust the volume in windows!

Comment by dogber1, Apr 13, 2009

if you set the volume in windows or in the signal player, you apply some kind of processing to the signal and it's not "bitperfect" anymore. whether or not this actuallly degrades quality is another discussion.

Comment by gfv000, Apr 27, 2009

Are these C-Media chipsets limited to 16bit 96kHz even with your driver? If so, what h/w is needed to get "bitperfect" 96kHz 24bit audio data from a SPDIF output on PC with windows XP?

Thanks.

Comment by dogber1, May 02, 2009

The C-Media chipsets seem to be indeed limited to 16 bit audio. I haven't got material which is encoded in 24 bit resolution, and considering the harsh requirements on jitter for this, I very much doubt that it's a sensible choice, so I haven't bothered to look for 24 bit hardware.


Sign in to add a comment
Hosted by Google Code