You are on page 1of 63

DSP Basics

Dilpreet Singh

Introduction to DSP
The aim of this session is to introduce the
fundamental concepts and technology of
Digital Signal Processing.
For brevity and perhaps clarity, this initial
presentation on the course is made with a
minimum of mathematics.
Where appropriate and possible, intuitive
descriptions and definitions of DSP theory,
concepts and algorithms will be given.
History
In the 1980s the introduction of the microprocessor (Intel 8086
Rockwell 6502 etc) caused the so called Microprocessor
Revolution or Data Processing Revolution.
Computer equipment became low cost and widely available.
Aside from many early 1980s home computers and games
machines, the main innovation was IBM-PC in 1980 and the
Macintosh in 1984.
This proliferation of computers in the office, in industry and
home completely changed everyday working practice, and the
way information is stored and processed.
FOR MORE INFO...
Refers to online docs for DSP Evolution
DSP Revolution
Early 1980s : Special purpose DSP Microprocessors
introduced.
Early 1990s : Processing power of DSP processors
has increased by an order of magnitude, and price
decreased.
The Reliability, Repeatability and Programmability of
DSP has widely displaced analogues systems in both
consumer and industrial markets
Digital
Telephony
Multimedia
computing
CD Audio
Biomedical DSP
Digital Mobile
Mobile multimedia
Teleconferencing
Digital video
Years
2000 1990 1980 1970
1
10
100
1000
P
r
o
c
e
s
s
i
n
g

P
o
w
e
r











i
n

M
I
P
S

Personal Computer
IBM-PC of the 1980s has evolved in a Multimedia PC enabled by DSP technology and
algorithms

Windows95 - 98 and NT Facilities
for speech coding/compression (ADPCM,
LPC, GSM, etc)
Digital filtering, FFT, correlation facilities
all within Microsoft Excel spreadsheet...

Speech Processing : DSP
enabled digital recording answering
machine. Speech synthesis, Speech
recognition
Teleconferencing Card :
enabled by DSP audio and
adaptive acoustic echo cancellation
Fax/Modem : enabled by
adaptive digital signal processing
algorithms for echo cancelling, data
equalisation.
Video Acquisition Card Fast
ADC/DAC technology and DSP
video coding algorithms for MPEG,
FFTs, DCTs, subband coding etc...
Sound-Card 16 bit sound technology
sampling up to 48Khz. Sigma-Delta
technology allows low cost
implementation; DSP processors
implement algorithms for decimation,
interpolation, mixing, filtering, coding etc...
ASIC, FPGA, DSPs, VLSI
Application Specific Integrated Circuits (ASICs) widely developed for specific purposes.
Mixed analogue/digital circuits achievable with VLSI CMOS.
DSP Classification
Digital
Image Processing
Digital
Speech Processing
Advance topic
(VLSI DSP)
Error Control
Coding
Recognition
Understanding
DSP Processing
Application Specific System
Efficient Communication System
Reliable Communication System
Secure Communication system
Coding
Techniques
Data
Compression
DSP
Applications
Biomedical data processing. EEG, ECG(EKG), CT
Digital Audio
Sonar and Radar processing:homeland security, video
surveillance,
military applications.
Speech processing
Data Communication.
Image Processing.
Information security.
Error correction
Oil exploration.
Under water mapping (Seismic signal Processing).
And many more ..
System
A system is a collection of physical components or
processes that act to change a physical quantity or
signal
Systems may convert signals from one form to
another (i.e. mechanical to electrical and vice versa)
System Examples:
Loudspeakers and microphones
Analog and digital filters
Rooms
The ocean or atmosphere
Mechanical structures
Control systems
Gearbox and bearings
System
Any process that results in the transformation of an
input (excitation) into an output (response).







Systems are modeled as transformations or operators
that map input signals to outputs

X (t) y (t) Continuous-Time system
X [n] y [n] Discrete-Time System
System, T[.]
Input
(excitation)
Output
(response)

Y [n] = T {x [n]}
Signal Classification
X (t)





t
Analog
X (t)





t
Discrete
X (t)






t
Digital
X (t)






t
Sample-Data
Continuous Time Discrete Time
Continuous
Amplitude
Discrete
Amplitude
Discrete-Time Signals:
Time-Domain Representation
Signals represented as sequences of numbers,
called samples
Sample value of a typical signal or sequence
denoted as x[n] with n being an integer in
the range
x[n] defined only for integer values of n and
undefined for noninteger values of n
Discrete-time signal represented by {x[n]}
Discrete-Time Signals:
Time-Domain Representation
Discrete-time signal may also be written as a sequence of
numbers inside braces:
{x [n]} = { , 0.2,2.2,1.1,0.2, 3.7,2.9, }

In the above,etc.
x[1] = 0.2, x[0] = 2.2, x[1] =1.1,
Graphical representation of a discrete-time signal with
real-valued samples is as shown below:
Cont..
In some applications, a discrete-time sequence {x[n]}
may be generated by periodically sampling a continuous-
time signal x a ( t ) at uniform intervals of time
Block Diagram (DSP)
This can be used for any analog Waveform.
Digital to Analog
Conversion
- Sample and Hold
Low pass
Filter
Low pass
Filter
Analog to Digital
Conversion
-Sampling
- Quantization
Digital Processes
Analog Signal
Input
Analog Signal
output
Band-limited Signal
Properties of the System
Causal System: The output at any time n1 depends
only on values of the input at the present time and in
the past (i.e. n <= n1).i.e. The system is
nonanticipative about future inputs

Sample: y[n] =10x[n] + 3x[n-1] +x[n-4]
Causality
All natural systems are causal. (unless fortune tellers
exist!!!)
Noncausal systems are also possible in
engineering.
Offline processing of data (issue of time can be
ignored)
Image analysis (not with respect to time!)
Examples of causal and noncausal systems:
The current motion of a plane relies only on
present and past actions of the pilot, and not on
the future actions of the pilot. Therefore it is a
causal.
Ideal unitdelay, y[n] = x[n 1] is causal.
Ideal predictor, y[n] = x[n + 1] is noncausal
Memory Less
Memoryless System: The output at any time n1
depends only on values of the input at the present
time (i.e. n = n1).

Sample: y[n] = 10x[n]
Memoryless systems are a special case of causal
systems.If past inputs are used, then the system
has memory.
Example:A resistor is memoryless, whereas a
capacitor has memory.
Linearity
Linear: A system is linear if it obeys the two
properties of superposition as follows:
Scaling: Ax1[n] Ay1[n]
ex: Doubling the input will double the
output.
Additivity: x1[n]+x2[n] y1[n]+y2[n]
ex: Adding two inputs gives an output that
is the sum of the individual outputs.
Cont..
Scaling and additivity for a linear system can
be written as:
X [n]= Ax1[n]+ Bx2[n] y [n] = Ay1[n] + By2[n]
Example of superposition equivalence:
(input #1) Vocal tract and
(input #2) background piano played separately
(sum/scaling) and combined with a mixer
(system) then recorded
(output) gives musical recording.
(input) Vocal tract and guitar played together
(system) and recorded
(output) gives musical recording
Linear System
System Equivalence: Consider two scaled sequences
passed through the same linear system
Linear System
Same
Linear System

Same
Linear System

Ax1[n]
Ax2[n]
Ay1[n]
Ax1[n] + Ax2[n]
Ay2[n]
Ay1[n] +Ay2[n]
Since the system is Linear, then
Testing the Linearity
Testing for Linearity
System
System
System
System is Linear Only if
Y [n] = w [n]
x1[n]
x2[n]
y1[n]
y2[n]
+
+
x1[n]
x1[n]
A
B
A
B
w [n]
y [n]
X [n]
Time- Invariance
Timeshifting the input will cause the same
timeshift in the output.
Equivalently:
Can prove that the time origin (n = 0) can be picked
arbitrarily.
Example of timeinvariant system:
(inputsignal) A music CD
(system) when played back on a CD player
(output signal) produces the same sound
(timeinvariance) whether played today or
tomorrow.
Time Invariance
Example: If the input x[n] to a timeinvariant system
produces the following output y[n]
Time-Invariant
System
Time-Invariant
System
0 1 2 3 4
X[n-2]
-1 0 1 2 3 4
X [n]
Y [n]
w [n]
n
n
n
n
0 1 2 3 4 6 7 8
5
-1
-1 0 1 2 4
3
-1
1
2
3
3
1
2
then a timeshifted input produces the same shift in the output
Stability
Stability: An intuitive definition of stability is that
small inputs to a system lead to outputs that do not
diverge.
Bounded input, bounded output (BIBO) is a more
formal way of evaluating the stability of a system.
Stable
System
Unstable
System
Bounds
On Inputs
Bounds
On output
No Bounds
On output
A system is stable in the BIBO sense if and only if every bounded input to the system
produces a bounded response
LTI - System
Linear TimeInvariant System (LTI):
A system is LTI if it is both linear and timeinvariant.


Why study LTI systems?
If signal = linear combination of time shifted simpler
signals
Then
overall response = simpler responses scaled/time
shifted
LTI
System
X [n]
y [n]
Discrete Fourier Transforms
Consider finite duration signal

Its z - transform is

Evaluate at points on z-plane as



We can evaluate N independent points
{ } 1 ... 0 ) ( = N n n x

=

=

1
0
). ( ) (
N
n
n
z n x z X

= =

=
1
0
2
) ( ) ( ) (
N
n
kn
N
j
k
z
e n x z X k X
t
Discrete Fourier Transforms


This is known as the Discrete Fourier
Transform (DFT) of
Periodic in k i.e.
This is as expected since the spectrum
is periodic in frequency
{ } ) (n x
) ( ) ( k X pN k X = +

=

=
1
0
2
) ( ) (
N
n
kn
N
j
e n x k X
t
Discrete Fourier Transforms
Multiply both sides of the DFT by
And add over the frequency index k



From which
km
N
j
e
t 2

=

=

=
1
0
1
0
) (
2
1
0
2
) ( ) (
N
n
N
k
n m k
N
j N
k
km
N
j
e n x e k X
t t

=

=
1
0
2
). (
1
) (
N
k
kn
N
j
e k X
N
n x
t
Discrete Fourier Transforms
This is the inverse DFT


That is a) the DFT assumes that we
deal with periodic signals in the time
domain
b) Sampling in one domain
produces periodic behaviour in the other
domain

=

=
1
0
2
). (
1
) (
N
k
kn
N
j
e k X
N
n x
t
) ( ) ( n x qN n x = +
Discrete Fourier Transforms
Effectively by knowing
is known everywhere since


or
) ( ) ( k X z X
k
z z
=
=
) (z X

=

=

=

=

1
0
1
0
2
1
0
) (
1
). ( ) (
N
n
N
k
n
kn
N
j N
n
n
z e k X
N
z n x z X
t

=

=

1
0
1
2
. 1
1
). (
1
) (
N
k
k
N
j
N
z e
z
k X
N
z X
t
Discrete Fourier Transforms
The formula



This is essentially an interpolation and
forms the basis of the Frequency
Sampling Method for FIR digital filter
design

=

=

1
0
1
2
. 1
1
). (
1
) (
N
k
k
N
j
N
z e
z
k X
N
z X
t
Convolution in DFT
Consider the following transform pairs

Define
Find
{ } ) ( ) ( k X n x
p p

{ } ) ( ) ( k H n h
p p

) ( ). ( ) ( k X k H k Y
p p p
=
)] ( [ IDFT ) ( k Y n y
p p
A
=
Convolution in DFT
From IDFT


However

=

=

=
1
0
2
1
0
2
). ( ). (
1
). (
1
) (
N
k
kn
N
j
p p
N
k
kn
N
j
p p
e k X k H
N
e k Y
N
n y
t t

=

=
1
0
2
) ( ) (
N
m
km
N
j
p p
e m h k H
t

=

=

=
1
0
1
0
2 2
). ( . ). (
1
) (
N
k
N
m
kn
N
j
p
km
N
j
p p
e k X e m h
N
n y
t t
Convolution in DFT
Or


Thus


This the Circular Convolution

=

=

=
1
0
) (
1
0
) (
2
). (
1
). ( ) (
N
m
m n
p
x
N
k
m n k
N
j
p p p
e k X
N
m h n y

t

=

=
1
0
) ( ). ( ) (
N
m
p p p
m n x m h n y
Computation of the DFT: The
FFT Algorithm
Computation of DFT requires for every
sample N multiplications. There are N
samples to be computed i.e. time
consuming operations.
The Fast Fourier Algorithm:(Decimation
in time - DIT, assume even no. of
samples)
set
2
N
) 2 ( ) (
1
n x n x = ) 1 2 ( ) (
2
+ = n x n x
1
2
,..., 1 , 0 =
N
n
FFT
Then DFT of is written


set
)} ( { n x

+ =

=

=
1
even
0
1
odd
0
). ( ). ( ) (
N
n
N
n
nk
N
nk
N
W n x W n x k X
N
j
N
e W
t 2

=
2
) 2 (
2
2
N
N
j
N
W e W = =
t
FFT
ie

Or
Computations of each of summations is
now of order ,and thus total
computational effort is reduced to .
Continuation of divide-&-compute
reduces effort to Nlog(N)

+ =

=

=
1
2
0
1
2
0
2
2
2
1
). ( ). ( ) (
N
n
N
n
nk
N
k
N
nk
N
W n x W W n x k X
) ( ) ( ) (
2 1
k X W k X k X
k
N
+ =
2
) 2 / (N
2 /
2
N
8-point FFT
8-point Signal Flow Diagram
X(0)
X(1)
X(2)
X(3)
X(4)
X(5)
X(6)
X(7)
x(0)
x(1)
x(2)
x(3)
x(4)
x(5)
x(6)
x(7)
a
b
FFT times
Time (1 multiplication per microsec)
19 3 days 4
hrs
26214
4
2
1 hr 11 mins
32768
.2 67 4096
.02 sec
1 512
.002 Sec
.02 sec 64
FFT
Direct DFT
N
6
2
9
2
12
2
15
2
18
2
Decimation-in-Time FFT Algorithm
In the basic module two output variables
are generated by a weighted
combination of two input variables as
indicated below
where and



Basic computational module is called a
butterfly computation
, , 2 , 1 = r
1 , , 1 , 0 , = | o N
Decimation-in-Time FFT Algorithm
Input-output relations of the basic
module are:


Substituting in the
second equation given above we get
] [ ] [ ] [
1
| o o
r N r r
W + + + = +
+

] [ ] [ ] [
) 2 / (
1
| o |
r
N
N
r r
W + + + = +
+
+

] [ ] [ ] [
1
| o |
r N r r
W + + = +
+


N
N
N
W W =
+ ) 2 / (
Decimation-in-Time FFT Algorithm
Modified butterfly computation requires
only one complex multiplication as
indicated below



Use of the above modified butterfly
computation module reduces the total
number of complex multiplications by
50%
Decimation-in-Time FFT
Algorithm
New flow-graph using the modified
butterfly computational module for N = 8
Decimation-in-Time FFT
Algorithm
Computational complexity can be reduced
further by avoiding multiplications by ,
, , and
The DFT computation algorithm described here
also is efficient with regard to memory
requirements
Note: Each stage employs the same butterfly
computation to compute and
from and
1
0
=
N
W
1
2 /
=
N
N
W j W
N
N
=
4 /
j W
N
N
=
4 / 3
] [
1
o
+
+
r
] [
1
|
+
+
r
] [|
r
+ ] [o
r
+
Audio Signal Processing

Sound Processing-One of the many
applications of DSP
The effects of basic DSP operations are
noticeable in sound
Audio signal processing includes a wide
variety of effects and filtering
techniques.
Sound Effects
Echo
Reverberation
Flanging
Equalizer
Fading
Pitch shifting
Echo
Repetition of a sound by reflection of sound waves
from a surface.
Echo rises in Communication systems, when signals
encounter a mismatch in impedance

Implementation :
Delay is the building block for a number of effects including
echo
If the delay is more than 50-70 ms, it is perceptible to human
ear as an echo
Block Diagram




Audio signal is delayed, and played back
superimposed on the original signal after the
delay time, creating echo (several
milliseconds to several seconds)
Delay
+
Input
Delay Mixer
Output
Echo Delay

Original Audio Sound
Delayed Audio Sound
ECHO
50 70 ms Delay
+
Multiple Echoes

Original Audio Sound
Delayed Audio Sound
Multiple Echo
50 70 ms Delay
+
Delayed Audio Sound
Delayed Audio Sound
50 70 ms Delay
50 70 ms Delay
+
+
Reverberation
Reverberation is a result of the many reflections that
occur in a room. The series of delayed and
attenuated sound waves combine to form a
reverberated sound
Sound Source Listener
Implementation
Implementation involves a filter which realizes a infinite
number of echoes spaced R sampling periods apart with
exponentially decaying amplitude.

H (z) = Z-R

For all pass filter
H (z) = alpha + Z-R
1 + alpha Z-R
Z-R
+
x [n] y [n]
alpha
1 + alpha Z-R Z-R
+
+
+
x [n]
y [n]
-1
alpha
Schroeders Reverberator
Combination -4 Comb and 2 All Pass.
FOR MORE INFO...
Flanging
Flanging has a very characteristics sound that many
people refer to as whooshing sound.

In a flanger, the length of the delay is constantly
changing .The typical delay is from 1-10ms. Since,
the human ear will perceive an echo only if the delay
is more than 50-70ms, hence the whoosh..

Flanging creates a set of equally spaced notches in
the audio spectrum. As these notches resemble the
teeth of a comb, the flangeris sometimes called a
comb filter.
Block Diagram
Flanging is created by mixing a signal, with a slightly
delayed copy of itself, where the length of the delay is
constantly changing.
H(Z) = ( 1 + alpha*( Z-beta(n)) )

Delay
+
Input
Depth
Output
Fading
In practice, we encounter channels whose
transmission characteristics vary with time. These
time variations owe to the random changes in the
propagation characteristic of the medium, causing
random attenuation of signal. This phenomenon is
known as fading.

Fading
Communication Systems: Fading is Channels
Characteristic
Practically, channels transmission characteristics
vary with time. These time variations owe to the
random changes in the propagation characteristic of
the medium, causing random attenuation of signal , a
phenomenon known as fading.
Audio Systems: Fading to cover eliminate any
unwanted glitches
gradually increasing the volume level (fade in) at the start of
a track
gradually decreasing the volume level (fade out) at the end
of a track
Pitch Shifting
Changing the pitch of a sound is often
desired for special effects, where the
original sound is shifted in frequency to
a point where it is no longer identifiable.
If the pitch is shifted down, the new
sound will have a longer duration.
If the pitch is shifted upwards, the sound
becomes shorter.
Pitch Shifting
Pitch Shifting can be accomplished by interpolating a
signal to a new sampling rate and then playing the
new samples back at the original sampling rate.

Equalizer
Equalization refers to a filtering process where the
frequency content of an audio signal is adjusted to
make sound better, adjust for room acoustics, or
remove noise that may be in a frequency band
different from the desired signal. By using a
combination of Low-pass, High-pass and Band-pass
filters, an audio equalizer can be built.
Equalizer
As an example we have implemented an equalizer
with three bands, a lower band, a middle band and
an upper band.
Low pass
Filter
Band Pass
Filter
High Pass
Filter
Input
Output
Procedures
Highlight any procedural differences
from regular projects of this type
Discuss requirements, benefits, and
issues of using new procedures
FOR MORE INFO...
List location or contact for procedures document (or other
related documents) here

You might also like