Digital Signal Processing

By Steven W. Smith, Ph.D.

- 1: The Breadth and Depth of DSP
- 2: Statistics, Probability and Noise
- 3: ADC and DAC
- 4: DSP Software
- 5: Linear Systems
- 6: Convolution
- 7: Properties of Convolution
- 8: The Discrete Fourier Transform
- 9: Applications of the DFT
- 10: Fourier Transform Properties
- 11: Fourier Transform Pairs
- 12: The Fast Fourier Transform
- 13: Continuous Signal Processing
- 14: Introduction to Digital Filters
- 15: Moving Average Filters
- 16: Windowed-Sinc Filters
- 17: Custom Filters
- 18: FFT Convolution
- 19: Recursive Filters
- 20: Chebyshev Filters
- 21: Filter Comparison
- 22: Audio Processing
- 23: Image Formation & Display
- 24: Linear Image Processing
- 25: Special Imaging Techniques
- 26: Neural Networks (and more!)
- 27: Data Compression
- 28: Digital Signal Processors
- 29: Getting Started with DSPs
- 30: Complex Numbers
- 31: The Complex Fourier Transform
- 32: The Laplace Transform
- 33: The z-Transform
- 34: Explaining Benford's Law

Your laser printer will thank you!

Characteristics of the Phase

In mathematical form: if *x*[*n*] ↔ *MagX*[*f*] & *PhaseX*[*f*], then a shift in the time domain results in: *x*[*n*+*s*] ↔ *MagX*[*f*] & *PhaseX*[*f*] + 2π*sf* (where *f* is
expressed as a fraction of the sampling rate, running between 0 and 0.5). In
words, a shift of *s* samples in the time domain leaves the magnitude unchanged,
but adds a linear term to the phase, 2π*sf*. Let's look at an example of how this
works.

Figure 10-3 shows how the phase is affected when the time domain waveform
is shifted to the left or right. The magnitude has not been included in this
illustration because it isn't interesting; it is not changed by the time domain
shift. In Figs. (a) through (d), the waveform is gradually shifted from having
the peak centered on sample 128, to having it centered on sample 0. This
sequence of graphs takes into account that the DFT views the time domain as
*circular*; when portions of the waveform exit to the right, they reappear on the
left.

The time domain waveform in Fig. 10-3 is symmetrical around a vertical axis,
that is, the left and right sides are mirror images of each other. As mentioned
in Chapter 7, signals with this type of symmetry are called *linear phase*, because
the phase of their frequency spectrum is a *straight line*. Likewise, signals that
don't have this left-right symmetry are called *nonlinear phase*, and have phases
that are something other than a straight line. Figures (e) through (h) show the
phase of the signals in (a) through (d). As described in Chapter 7, these phase
signals are *unwrapped*, allowing them to appear without the discontinuities
associated with keeping the value between π and -π.

When the time domain waveform is shifted to the right, the phase remains a
straight line, but experiences a *decrease* in slope. When the time domain is
shifted to the left, there is an *increase* in the slope. This is the main property
you need to remember from this section; a shift in the time domain corresponds
to changing the slope of the phase.

Figures (b) and (f) display a unique case where the phase is entirely zero. This
occurs when the time domain signal is *symmetrical* around sample *zero*. At first
glance, this symmetry may not be obvious in (b); it may appear that the signal
is symmetrical around sample 256 (i.e., *N*/2) instead. Remember that the DFT
views the time domain as circular, with sample zero inherently connected to
sample *N*-1. Any signal that is symmetrical around sample zero will also be
symmetrical around sample *N*/2, and vice versa. When using members of the
Fourier Transform family that do not view the time domain as periodic (such as
the DTFT), the symmetry must be around sample zero to produces a zero phase.

Figures (d) and (h) shows something of a riddle. First imagine that (d) was
formed by shifting the waveform in (c) slightly more to the right. This means
that the phase in (h) would have a slightly more negative slope than in (g). This
phase is shown as line 1. Next, imagine that (d) was formed by starting with
(a) and shifting it to the left. In this case, the phase should have a slightly more
positive slope than (e), as is illustrated by line 2. Lastly, notice that (d) is
symmetrical around sample *N*/2, and should therefore have a zero phase, as
illustrated by line 3. Which of these three phases is correct? They all are,
depending on how the π and 2π phase ambiguities (discussed in Chapter 8) are
arranged. For instance, every sample in line 2 differs from the corresponding
sample in line 1 by an integer multiple of 2π, making them equal. To relate line
3 to lines 1 and 2, the π ambiguities must also be taken into account.

To understand why the phase behaves as it does, imagine shifting a waveform
by *one* sample to the right. This means that all of the sinusoids that compose the
waveform must also be shifted by *one* sample to the right. Figure 10-4 shows
two sinusoids that might be a part of the waveform. In (a), the sine wave has a
very low frequency, and a one sample shift is only a small fraction of a full
cycle. In (b), the sinusoid has a frequency of one-half of the sampling rate, the
highest frequency that can exist in sampled data. A one sample shift at this
frequency is equal to an entire 1/2 cycle, or π radians. That is, when a shift is
expressed in terms of a phase change, it becomes *proportional* to the frequency
of the sinusoid being shifted.

For example, consider a waveform that is symmetrical around sample zero, and therefore has a zero phase. Figure 10-5a shows how the phase of this signal changes when it is shifted left or right. At the highest frequency, one-half of the sampling rate, the phase increases by π for each one sample shift to the left, and decreases by π for each one sample shift to the right. At zero frequency there is no phase shift, and all of the frequencies between follow in a straight line.

All of the examples we have used so far are *linear* phase. Figure 10-5b shows
that *nonlinear* phase signals react to shifting in the same way. In this example
the nonlinear phase is a straight line with two rectangular pulses. When the
time domain is shifted, these nonlinear features are simply superimposed on the
changing slope.

What happens in the *real* and *imaginary parts* when the time domain waveform
is shifted? Recall that frequency domain signals in rectangular notation are
nearly impossible for humans to understand. The real and imaginary parts
typically look like random oscillations with no apparent pattern. When the time
domain signal is shifted, the wiggly patterns of the real and imaginary parts
become even more oscillatory and difficult to interpret. Don't waste your time
trying to understand these signals, or how they are changed by time domain
shifting.

Figure 10-6 is an interesting demonstration of what information is contained in
the *phase*, and what information is contained in the *magnitude*. The waveform
in (a) has two very distinct features: a rising edge at sample number 55, and a
falling edge at sample number 110. Edges are very important when
information is encoded in the *shape* of a waveform. An edge indicates *when*
something happens, dividing whatever is on the left from whatever is on the
right. It is time domain encoded information in its purest form. To begin the
demonstration, the DFT is taken of the signal in (a), and the frequency spectrum
converted into polar notation. To find the signal in (b), the phase is replaced
with random numbers between -π and π, and the inverse DFT used to
reconstruct the time domain waveform. In other words, (b) is based only on the
information contained in the *magnitude*. In a similar manner, (c) is found by
replacing the magnitude with small random numbers before using the inverse
DFT. This makes the reconstruction of (c) based solely on the information
contained in the *phase*.

The result? The locations of the edges are clearly present in (c), but totally
absent in (b). This is because an edge is formed when many sinusoids *rise* at the
same location, possible only when their *phases* are coordinated. In short, much
of the information about the shape of the time domain waveform is contained
in the *phase*, rather than the *magnitude*. This can be contrasted with signals that
have their information encoded in the frequency domain, such as audio signals.
The magnitude is most important for these signals, with the phase playing only
a minor role. In later chapters we will see that this type of understanding
provides strategies for designing filters and other methods of processing signals.
Understanding how information is represented in signals is always the first step
in successful DSP.

Why does left-right symmetry correspond to a zero (or linear) phase? Figure
10-7 provides the answer. Such a signal can be decomposed into a left half and
a right half, as shown in (a), (b) and (c). The sample at the center of symmetry
(zero in this case) is divided equally between the left and right halves, allowing
the two sides to be perfect mirror images of each other. The magnitudes of
these two halves will be *identical*, as shown in (e) and (f), while the phases will
be opposite in sign, as in (h) and (i). Two important concepts fall out of this.
First, every signal that is symmetrical between the left and right will have a
linear phase *because* the nonlinear phase of the left half exactly cancels the
nonlinear phase of the right half.

Second, imagine flipping (b) such that it becomes (c). This left-right flip in the
time domain does nothing to the magnitude, but changes the sign of every point
in the phase. Likewise, changing the sign of the phase flips the time domain
signal left-for-right. If the signals are continuous, the flip is around zero. If the
signals are discrete, the flip is around sample zero *and* sample *N*/2,
simultaneously.

Changing the sign of the phase is a common enough operation that it is given
its own name and symbol. The name is complex conjugation, and it is
represented by placing a star to the upper-right of the variable. For example, if *X*[*f*]
consists of *MagX*[*f*] and *PhaseX*[*f*], then *X*^{*}[*f*] is called the *complex
conjugate* and is composed of *MagX*[*f*] and -*PhaseX*[*f*]. In rectangular
notation, the complex conjugate is found by leaving the real part alone, and
changing the sign of the imaginary part. In mathematical terms, if *X*[*f*] is
composed of *ReX*[*f*] and *ImX*[*f*], then *X*^{*}[*f*] is made up of *ReX*[*f*] and -*ImX*[*f*].

Here are several examples of how the complex conjugate is used in DSP. If *x*[*n*]
has a Fourier transform of *X*[*f*], then *x*[-*n*] has a Fourier transform of *X*^{∗}[*f*]. In words, flipping the time domain left-for-right corresponds to
changing the sign of the phase. As another example, recall from Chapter 7 that
correlation can be performed as a convolution. This is done by flipping one of
the signals left-for-right. In mathematical form, *a*[*n*] * *b*[*n*] is convolution, while *a*[*n*] * *b*[-*n*] is correlation. In the frequency domain these operations
correspond to *A*[*f*] × *B*[*f*] and *A*[*f*] × *B*^{*}[*f*], respectively. As the last example,
consider an arbitrary signal, *x*[*n*], and its frequency spectrum, *X*[*f*]. The frequency spectrum can be changed to *zero phase* by multiplying it by its
complex conjugate, that is, *X*[*f*] × *X*^{*}[*f*]. In words, whatever phase *X*[*f*] happens to have will be canceled by adding its opposite (remember, when frequency spectra are multiplied, their phases are added). In the time domain,
this means that *x*[*n*] * *x*[-*n*] (a signal convolved with a left-right flipped
version of itself) will have left-right symmetry around sample zero, regardless
of what *x*[*n*] is.

To many engineers and mathematicians, this kind of manipulation *is* DSP. If
you want to be able to communicate with this group, get used to using their
language.