Would you like to be notified by email when mnentwig publishes a new blog?
Keywords: Quantization noise; noise shaping
A brief introduction to noise shaping, with firm resolve not to miss the forest for the trees. We may still stumble over some assorted roots.
Matlab example code is included.
Fig. 1 shows a digital signal that is reduced to a lower bit width, for example a 16 bit signal being sent to a 12 bit digital-to-analog converter. Rounding to the nearest output value is obviously the best that can be done to minimize the error of each sample.
At least for noise-like signals (other signals may require dithering, which is out-of-scope here), the quantization error of each sample is independent, and the spectrum of the error is white. That is, it has equal power density at all frequencies.
Noise shaping can lower the quantization noise in some bandwidth of interest, but the price is always an increase in overall noise.
How does it work? The known quantization error of an output sample is used as the first sample of an arbitrary impulse response htarget, and the impulse response is completed by adding its remaining part later to the original signal, before quantization.
The impulse response htarget corresponds to a noise spectrum Htarget of my choice.
Figure 2 shows the impulse response htarget, scaled to match the instantaneous quantization error e with its first sample. Its remaining samples are then added to the future signal (before quantization).
Figure 3 shows the block diagram of a noise shaper that implements this idea.
Conceptually, the quantization error of each sample is calculated by subtracting the quantizer output from the input. An actual implementation might simply use the truncated bits.
This quantization error is now considered to be the first sample of a desired noise impulse response htarget. It is sent to a digital filter Hshaper that generates all the remaining samples of htarget, which are then added to the future input signal.
Htarget can be thought of as a digital filter that transforms random, white noise into the desired noise spectrum (it is also designed as a digital filter).
Hshaper is another filter closely related to Htarget: Given the first sample of htarget at its input, Hshaper outputs all future samples of htarget.
Hshaper can be derived from Htarget by normalizing it to the first impulse response sample, then subtracting this first sample. In other words: Scale to make its impulse response start with "1", then subtract "1" - now the impulse response hshaper starts with "0".
The calculation is straightforward if one remembers that the first output sample of an IIR filter depends only on b0, because all other coefficients refer to delay line contents, which are initially zero.
Fig. 4 shows the calculation. Hshaper can be found by comparing coefficients of z-1, z-2 etc. between a) and c).
Hshaper has no undelayed path and thus acts as a unit delay that makes it possible to implement the feedback loop formed by filter and quantizer.
The noise shaper can enforce any arbitrary shape to the noise spectrum, but there is a catch: As Hshaper is normalized (divided) by the first sample of htarget, an excessive magnitude of the added noise shaping signal will result if htarget starts up too slowly. Typically, this rules out attempts to suppress noise over a wide bandwidth.
For the same reason, a minimum-phase frequency response in Hshaper seems advantageous, as it minimizes the delay of energy in the impulse response over one that is non-minimum-phase , and thus tends to have a higher first sample.
The Gerzon-Craven noise shaping theorem formalizes these insights.
To illustrate this fundamental limitation, Figures 5 and 6 show two example frequency responses. The first (Fig. 5) attempts noise rejection only over a narrow frequency span. The resulting impulse response is well-behaved, with a large first sample.
The second frequency response (Fig. 6) attempts strong noise rejection over a much wider bandwidth. Its impulse response has a rather small first sample - barely visible in the plot - and normalizing this sample to "1" will cause the remaining impulse response to contribute a high level of unwanted noise, possibly achieving exactly the opposite of what was intended.
A Matlab / OctaveForge example is available for download (link at bottom of page). It designs an IIR bandstop filter for Htarget, as shown in Fig. 7, with a 4 MHz notch around 31 MHz at a sampling rate of 76.8 MSPS.
The filter is then converted into a noise shaper (using equations from Fig. 4), and applied to quantize a random signal. The resulting quantization error spectrum is shown in Fig. 8 (magenta), together with the equivalent output of a conventional quantizer without noise shaping (red).
Quantization error in the stopband of the filter is clearly reduced, whereas the total quantization error (integrated over all frequencies) increases as expected.
Finally, Figure 9 shows input and output signals in the time domain.
Looking at Figure 9, it should not be surprising that the structure in Fig. 3 oscillates by design: The differential gain of the quantizer in the feedback loop approaches infinity for levels close to any switching threshold. This is acceptable, because the error caused by an unlimited stairstep quantizer never exceeds half a "stairstep" in either direction. For bounded input, also bounded output of the filter may be guaranteed.
A multi-bit signal can be dimensioned so that digital clipping is a rare or even impossible event. One could make a solid argument that the objective for the noise shaper is to manage quantization, not clipping. Noise shaping on a wide bitwidth is common for example for the word length reduction of audio signals , such as the final step in mastering for 16-bit CD audio.
Noise shaping is also used in applications, where clipping is part of normal operation (i.e. one-bit sigma-delta modulation). Now no amplitude limit to the quantization (clipping) error is enforced. The noise shaping filter suddenly finds itself embedded in an instable feedback loop without amplitude limit. Signal values "run away" and the structure becomes non-functional.
Further discussion of the clipping problem can be found in  at the end of section 1. The design of stable sigma-delta modulators is a well-researched topic, but out-of-scope here.
This brief article introduces noise shaping by considering quantization error as first sample of a designed impulse response. An example program is included.
There are no comments yet!
Add a Comment