Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
The Dither: Noise + Averaging = Resolution topic discussed how added noise (dither) can actually increase data resolution when averaging is used. Here, we demonstrate how it reduces quantizing distortion in digital audio systems.
Below are (slightly reduced) screen shots of the waveform and spectrum of this signal. In the test system, the full-scale range was +/-1000 mV as shown on the waveform Y axis; your system may be uncalibrated or have a different full-scale range factor, so the Y axes may be different. Similarly, you may need to adjust the Max and Min values for X-axis eXpand to get the same X axes. Also, the color edit dialog was used here to change the Left Out trace color from green (default) to yellow, for better contrast in the reduced images.
Play WAV sample: 16-bit Sine (5 sec)
This signal is generated with default 16-bit resolution, and should sound very pure. If it had been a full-scale signal, it would use 2^16 = 65536 steps to form the sine wave. However, the level is set to 50% of full scale (Left Stream 0) so it only uses half of that range or 2^15 = 32768 steps.
This signal has very low quantizing distortion, which is visible as a noise floor in the spectrum at about 118 dB below the fundamental 440 Hz peak. (You can't see that in the right screen shot above, since the noise is well below the Y-axis range setting for compatibility with the following images. To see it, toggle Spectrum mode on, and make sure the default Hann Window is on in the Spectrum control dialog. Then hit PgUp several times until the noise floor is visible.)
This signal level is nearly as high as the highest peaks in most recorded music. The 32768 steps that make up the waveform are each only a tiny fraction of the total amplitude, so they are invisible on the screen and inaudible to your ears. But on softer musical passages where the instantaneous level is much lower, the steps are still the same absolute size and can become a significant fraction of the waveform amplitude.
To demonstrate that while maintaining an easy listening level, go to the Generator control dialog, find the Left Bits control (just under the Left Wave Controls button) and set it to 3. Now the full-scale range is only 2^3 = 8 steps, and the 50% level "sine wave" has become an up-down staircase with only 4 steps. (See the Bits topic to understand why they aren't vertically centered about zero.)
Play WAV sample: 3-bit Sine (5 sec)
This is quantizing distortion, and it sounds terrible. The spectrum confirms a forest of strong distortion products at odd multiples of the 440 Hz fundamental (3x = 1320, 5x = 2200, etc). This signal is equivalent to digitizing a pure sine wave at a level that is 8/65536 = 4/32768 = 0.0122% = -78.27 dB relative to the prior case, then playing it back with the volume boosted by the same amount.
In a real-world recording (without the above volume boosting) you'd hear a softer version of this distortion when the final note of a piano decayed into total silence at the end of a track. The note would sound clean at the start, but as it got softer and softer (such that the step size became a larger percentage of the waveform amplitude), the quantizing distortion would become evident as a buzzy tail just before the sound stopped. The problem is made worse by the fact that the first few odd harmonics are strongest, and they are in the frequency region where our ears are most sensitive.
The reason you don't hear this on current CDs is that the phenomenon became obvious back in the early days of digital audio. Designers had succeeded in creating recording preamps and consoles with ultra-low noise, in order to take advantage of digital's total lack of the surface noise that had previously plagued phonograph records and tapes. But when the noise levels fell below the size of the digital step size, quantizing distortion appeared.
The solution was to add dither to the signal before quantizing it to digital. To demonstrate this, click on the Left Wave Controls button. This will open the Left Stream 0 (L.0 Stream) dialog. Click on the 1 button at the top to change to Left Stream 1 (L.1 Stream), then click Stream On. This stream is set to create White noise at a level of 12.5%. This source has a uniform distribution, such that all amplitudes in the 12.5% range are equally probable. Note that 12.5% (1/8) is exactly one quantization step at the current 3-bit (8 steps) setting.
Daqarta sums all streams for a given channel (Left, in this case) before quantizing them down to the selected Bits setting. Here we are adding a 50% sine and a 12.5% noise, for 62.5% overall. The screen shot shows the waveform taking up 5 steps of 1/8 full-scale each, giving the expected 62.5%:
Play WAV sample: Uniform Dithered 3-bit Sine (5 sec)
Miraculously, the distortion peaks in the spectrum have vanished. Audibly, you hear only the original pure sine wave, plus noise. In fact, if you go back to the main Generator controls dialog and change Bits back and forth between 3 and 16, you can hear (and see in the spectrum) that the sine is unchanged; the only difference is that the noise is about 3 dB louder at 3 bits.
If all program material was as well-behaved as a single decaying piano note, this uniform dither would be all that was needed. Alas, there is another phenomenon called noise modulation that arises when there is an additional low-frequency component. You can hear this by going to Left Stream 3 and toggling Stream On. This adds a 1 Hz sine wave at a level of 12.5%.
Play WAV sample: Uniform Dithered 3-bit Sine with 1 Hz Noise Modulation (5 sec)
Now you can see the waveform sliding up and down the screen, and you can hear a "pumping", "swishing", or "breathing" sound at the 1 Hz rate. The cure for this is... more dither! But simply increasing the level of the uniform noise source isn't very effective; instead you add a second, independent, uniform noise source at the same 12.5% level. Do this by going to Left Stream 2 and toggling Stream On.
Note that adding two independent uniform noise sources, each at 12.5% level, is not the same as a single uniform source at 25%. For one thing, since the sources are independent, their sum is only 3 dB louder instead of the 6 dB you'd get from simply doubling a single source.
But more importantly, adding two uniform distributions produces a triangular distribution, which is ideal for this purpose because it eliminates noise modulation at the cost of only 3 dB more noise. (To understand why adding two uniforms gives a triangular distribution, see the Triangular Distributions subtopic under Changes Script Random Values. Although it deals with MIDI DaqMusiq production, it gives a simple numerical example.)
With triangular dither and the 1 Hz source from Stream 3, close your eyes and try to hear the noise modulation. Don't watch the screen, since that will bias your judgement. Alternatively, have an assistant toggle Stream 3 while you are out of the room, then you try to guess the state when you return. (Again, based only on the sound... no peeking!)
Play WAV sample: Triangular Dithered 3-Bit Sine reduces 1 Hz Noise Modulation (5 sec)
By now you should be convinced that dither really works... but how? The Dither: Noise + Averaging = Resolution topic explains how noise allows the average digitized values to approximate the original continuous input. But what about the present live audio case, where there is no averaging... or is there?
Consider that in computing the spectrum of this signal, the FFT process emulates a bank of sharply-tuned filters. Each "filter" performs an average that includes all 1024 samples in the FFT, which at the default 48000 Hz sample rate is 1024 / 48000 = 21.33 msec long. The spectral line (filter) at 3000 Hz, for example, detects waveform components that are 1/3000 second or 0.33 msec per cycle, so 64 cycles are included in each 21.33 msec sample set.
Likewise, the ear performs a multi-filter analysis by mechanical means, which necessarily have inertia, and thus effectively include averaging.
Historical note: "Dither" is a term and concept that greatly predates the digital era. It was used in mechanical and hydraulic systems to eliminate problems with static friction. Where static friction was much greater than dynamic friction, a system needed a large force to overcome static friction when getting started; then the friction would suddenly drop off and the system would lurch ahead. Dither was typically a small vibratory motion that kept the system in the dynamic friction range for smooth starting.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved