v3 by keralaguest


									Draft                                       Page 1                                      12/4/11

   An Introduction to Digital Signal Processing in Java

By Douglas Lyon

Digital signal processing is a kind of data processing that works on a set of elements. The
elements in the set can be numbers or symbols. Typically, one dimensional signal
processing works on a vector of numeric data that represents a signal.

For example, soundis a pressure wave that traverses a medium. Sound pressure waves in
air are the objective cause of human hearing. Sound will not travel through a vacuum, but
it will travel through various phases of matter (solid, liquid and gas).

A transducer is a device that takes power from one system and supplies power to another.
For example, a microphone is a transducer that takes sound power and supplies electrical
power. The electrical power supplied by the microphone forms a signal that is analog. An
analog signal is continuous.

Digitization is a process that converts a continuous signal into a digital form. Digitization
(also known as analog to digital conversion) is performed by sampling and quantization.
Sampling is the process of converting a continuous signal into a set of voltages.
Quantization is the process of converting the sampled voltages into a countable set of
digital values. Analog data that is converted to digital data is said to be PCM encoded.
PCM stands for Pulse Code Modulationand is a broad term that can refer to any type of
digital encoding of analog data. Figure 1 depicts a PCM encoder.

                         Figure 1. Block diagram of a PCM encoder

A low-pass filter (called an anti-aliasing filter) is typically set to attenuate frequencies at
or above one-half the analog to digital converters’ sampling rate (this is known as the
Nyquest frequency).

To transform the PCM signal back into the analog domain, we couple a digital-to-analog
converter with another low-pass filter. A block diagram of the PCM decoder is shown in
Figure 2.

                         Figure 2. Block diagram of a PCM decoder

Digital signal processing is a kind of data processing that operates on PCM data. Thus,
broadly speaking, audio, image and image sequence processing are 1-D, 2-D and 3-D
digital signal processing.

                                      lyon@docjava.com                                 9:00 PM
Draft                                      Page 2                                    12/4/11

In common usage, the term digital signal processing refers to one dimensional signals,
EMBED "Equation" \* mergeformat . In image processing we often speak about two
dimensional signals, EMBED "Equation" \* mergeformat . This chapter deals only with
one-dimensional digital signal processing in Java.

5.2. Why do we need digital signal processing?

A digital signal stream may come from any energy (i.e., sound, measurement,
temperature, speed, pressure, radiation, etc.). There also exist non-physical phenomena
that can produce a digital stream of data (i.e., financial data, statistical data, network
traffic, etc.).

In short, digital signal processing may be performed on any recordable event. Digital
signal processing is just a kind of data processing.

In this chapter we treat only the restricted domain of audio digital signal processing in
Java. There are several reason for this;
  1. Java can already play audio files.
  2. The techniques may be extended to other types of data.
  3. We can hear the results.
  4. It is fun!

5.3. What is the spectrum of a signal?

The harmonic content of a signal is called the spectrum of the signal. The spectrum of a
signal consists of a series of sin and cosine waves. Spectra is the plural form of spectrum.
A French mathematician, Jean Baptist Joseph de Fourier (1768-1830), showed that
harmonic waves (i.e., sine and cosine waves) may be summed in a series to form any
periodic waveform. The summation (called the superposition principle) fails to
approximate a waveform when the equations governing the waveform are non-linear (i.e.,
shock waves, turbulence, chaos, etc.) [Halliday]. The series was first formulated by, and
is used in, harmonic analysis (also called Fourier analysis). Harmonic analysis is the
process that determines the harmonic components of a complex wave. The series may be
written as

where are constants called Fourier coefficients.

For example, a sawtooth wave may be computed by letting k in

go to infinity. When k=5, the waveform of Figure 3 results:

                                    lyon@docjava.com                                9:00 PM
Draft                                       Page 3                              12/4/11


           0          0.5          1       1.5        2       2.5     3



                            Figure 3. Sawtooth waveform with k=10

When k=100, the waveform of Figure 4 is produced.


           0          0.5          1       1.5        2       2.5     3



                            Figure 4. Sawtooth waveform with k=100

When the waveform to be approximated is not periodic, the summation is replaced by the
Fourier transform:



Where is given by Euler’s identity:

                                       lyon@docjava.com                        9:00 PM
Draft                                          Page 4                                12/4/11


Euler’s identity can lead to several equivalent representations for the Fourier series. For
example there is the Sine-Cosine Representation

where and . The constants, known as Fourier coefficients, are found by correlating the
time dependent function, x(t), with a Nth harmonic sine-cosine pair:


Another common representation of the Fourier series is the amplitude-phase
representation. This is also a result of the Euler’s identity:

In general the usage of the representation of the Fourier transform is a matter of
preference, as the various representations are equivalent. There are some interesting
properties of the Fourier transform, and while it is beyond this scope to state them all (or
to prove any of them), we do give some of them here.

A Fourier transform representation of an a periodic signal has discrete spectral
components at , as shown by (5.1). An aperiodic signal as a continuous and infinite
spectrum, as shown by (5.2) and (5.3). This means that time-limited signals (which are,
by definition, aperiodic) have infinite bandwidth.

The effective bandwidth of a signal is the width of the spectra which contains the most
power. The average power in a given interval of time is computed by . To compute the
average power in a periodic signal, whose period is T, we use . The (Power Spectral
Density) is the power at a specific frequency, .

The Fourier transforms are important because they permit computation in either the time-
domain or in the frequency domain. Some relations with Fourier transform follow:

Superposition state that linear combinations in the time domain become linear
combinations in the frequency domain:


Delay in the time domain causes a phase shift in the frequency domain:

Scale change in the time domain causes a reciprocal scale change in the frequency

                                     lyon@docjava.com                               9:00 PM
Draft                                         Page 5                                  12/4/11


The convolution theorem state that multiplication in the time domain causes convolution
in the frequency domain:


Where convolution between two functions of the same variable is defined by:


For proofs of these results, see [Carlson].

5.4. What does sampling do to the spectrum of a signal?

The digitization process, as depicted in Figure 1, starts with the process of sampling. The
sampling-reconstruction process does not have to perform digitization, and yet is still
responsible for the introduction of additional harmonic content into the reconstructed
signal. The sampling-reconstruction process is shown in Figure 5.

          v(t)                               R             low -pass         output
                                          Amplifier        filter
                      Figure 5. The Sampling-Reconstruction process

Figure 5 shows a continuous signal, v(t) being sampled at a rate of using an electronically
controlled switch. The output of the switch is fed into an amplifier that has a gain of R.
Mathematically, the sampling function may be expressed in terms of a Dirac delta
function multiplied by v(t) in the time domain. The Dirac delta function, EMBED
"Equation" \* mergeformat , is a generalized function that is defined by:

Where is arbitrarily small. Thus the Dirac delta function is a unit impluse that occurs at
time t=0. We can make the Dirac delta function fire at any time, , by using the form

                                          .                                     (5.11)

Further, we can model the sampling function as an infinite sum of Dirac delta functions:

The switching function multiples s(t) by v(t). The sampled function is represented by

                                    lyon@docjava.com                               9:00 PM
Draft                                     Page 6                                   12/4/11


Recall that multiplication in the time domain is convolution in the frequency domain:


The Fourier transform of an impulse train is also an impulse train


Finally we see that sampling a signal at a rate of causes the spectrum to be reproduced at


A sample of this spectrum replication is shown in Figure 5.6.

                     Figure 5.6 Spectrum replication due to sampling

Equation (5.16) is called the aliasing formula.

                                    lyon@docjava.com                              9:00 PM

To top