This site uses cookies to deliver our services and to show you relevant ads and job listings. By using our site, you acknowledge that you have read and understand our Cookie Policy , Privacy Policy , and our Terms of Service . Your use of the Related Sites, including DSPRelated.com, FPGARelated.com, EmbeddedRelated.com and Electronics-Related.com, is subject to these policies and terms.

eywords: 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.

Quantization

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.



Figure 1: Quantization (reduction of bit width)

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 h target , and the impulse response is completed by adding its remaining part later to the original signal, before quantization.



The impulse response h target corresponds to a noise spectrum H target of my choice.



Figure 2 shows the impulse response h target , 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 2: Noise shaping: Quantization error becomes the first sample of an impulse response

Figure 3 shows the block diagram of a noise shaper that implements this idea.



Figure 3: Block diagram of noise shaper

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 h target . It is sent to a digital filter H shaper that generates all the remaining samples of h target , which are then added to the future input signal.

Filter design

H target 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).



H shaper is another filter closely related to H target : Given the first sample of h target at its input, H shaper outputs all future samples of h target .



H shaper can be derived from H target 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 h shaper starts with "0".



The calculation is straightforward if one remembers that the first output sample of an IIR filter depends only on b 0 , because all other coefficients refer to delay line contents, which are initially zero.



Figure 4: Derivation of noise shaper filter from targeted frequency response

Fig. 4 shows the calculation. H shaper can be found by comparing coefficients of z-1, z-2 etc. between a) and c).



H shaper 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.

Fundamental limits

The noise shaper can enforce any arbitrary shape to the noise spectrum, but there is a catch: As H shaper is normalized (divided) by the first sample of h target , an excessive magnitude of the added noise shaping signal will result if h target 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 H shaper seems advantageous, as it minimizes the delay of energy in the impulse response over one that is non-minimum-phase [4], 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.



Figure 5: Attempt to suppress noise in a narrow bandwidth only (good)

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.



Figure 6: Attempt to achieve wide-band noise suppression (bad)

Example code

A Matlab / OctaveForge example is available for download (link at bottom of page). It designs an IIR bandstop filter for H target , as shown in Fig. 7, with a 4 MHz notch around 31 MHz at a sampling rate of 76.8 MSPS.



Figure 7: Example H Target , an IIR filter design

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.



Figure 8: quantized output spectrum with and without noise shaping

Finally, Figure 9 shows input and output signals in the time domain.



Figure 9: input and output waveform

Quantization, clipping and stability

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 [1], 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 [2] at the end of section 1. The design of stable sigma-delta modulators is a well-researched topic, but out-of-scope here.

Summary

This brief article introduces noise shaping by considering quantization error as first sample of a designed impulse response. An example program is included.

Download

The program (Octave / Matlab) can be downloaded here . It requires this spectrum analyzer code snippet in the same folder.

References

[1] Hydrogen Audio: Noise shaping Wiki

[2] Why 1 bit Sigma-Delta conversion is unsuitable for High Quality applications

[3] When is noise shaping useful? comp.dsp discussion

[4] Wikipedia: Minimum phase