DSP Basics: Dr. Twe Ta Oo Lecturer Faculty of Computer Systems and Technologies University of Computer Studies, Yangon
DSP Basics: Dr. Twe Ta Oo Lecturer Faculty of Computer Systems and Technologies University of Computer Studies, Yangon
Lecture I
DSP Basics
Dr. Twe Ta Oo
Lecturer
Faculty of Computer Systems and Technologies
University of Computer Studies, Yangon
1
Acknowledgement:
Some of the contents are prepared according to online materials.
Lecture Contents
Part I:
What is Digital Signal Processing (DSP)?
Signal basics
4/29/2020
Systems and their properties
Sound creation and its intensity
Sound intensity in dB scale
Part II:
Analog to digital conversion
Sampling
Quantization
Encoding 2
4/29/2020
numbers (ADC),
the processing of these sequences by numerical
computation techniques (digital signal processor), and
the conversion of such sequences into analog signals
(DAC).
3
Signal Basics
Something that conveys information
e.g. speech signal, image signal, video signal, etc.
Represented by a function of independent variables such
4/29/2020
as time, distance, space, etc.
e.g. Speech and music signals represent air pressure
as a function of time.
Basic element – sample
4/29/2020
Fig. An image signal i(x,y) (two dimension).
5
Fig. A video signal (multi-dimension).
Sound Creation and Propagation
Sound originates from the disturbance of the air by any object.
E.g. Two hands clapping cause a disturbance of the air
around the hands.
4/29/2020
The hands are the source of the sound.
The local region of air has gained energy caused by the motion
of the air molecules. This energy spreads outwards in sound
waves.
Sound travels through the air at about 340 metres per second.
6
7
4/29/2020
Sound − Representation
Sound is often represented diagrammatically as a sine wave.
The wave crests can be considered as the pressure maxima,
whilst the troughs represent the pressure minima.
4/29/2020
crest through
8
Sound − Physical Variables
Two physical measurements describe the sound wave
completely: the amplitude (A) and the period (T).
We usually speak, not of the period, but of the frequency (f) of
4/29/2020
vibrations, which is simply the inverse of the period (i.e. 1/T).
Amplitud
number of waves that travel by
in each unit of time.
e
It is usually measured in Hertz T
(Hz, cycle per second) (1 kHz =
1000 Hz).
The range of human hearing is from 20 Hz
to 20 kHz. 9
2kHz − 4kHz are easiest to perceive (detectable at a
relatively low volume);
Sound − Physical Variables (cont.)
The distance per cycle is named as wavelength of the
sound wave (λ):
4/29/2020
λ =where
c /f, c = sound velocity and f = frequency.
10
Sound Intensity
Sound intensity is a measure of power for a sound, as it
contacts an area such as the eardrum and directly
proportional to the square of the amplitude of the waveform.
4/29/2020
The intensity as a function of the pressure is:
I(t) = x2(t)/ρc.
4/29/2020
Acousticians use the dB scale for the following reasons:
1. Quantities of interest often exhibit such huge ranges of
variation that a dB scale is more convenient than a linear
scale.
2. The human ear interprets loudness more easily represented
with a logarithmic scale than with a linear scale.
4/29/2020
where X1 is reference pressure level and I1 is reference intensity
level.
An absolute acoustical decibel, dB scale is referenced to the
minimal threshold of hearing.
The reference pressure is 20 μPa and it is the minimal
threshold of hearing at 1,000 Hz for most people.
The reference intensity is derived as follows.
12 12
I1 (20 ) /(415) 0.964 10
2 2
I1 X 12 /( c), 10 W / m
13 4/29/2020
dB SIL & dB SPL
I2 CX 2
2
CX 2
dB SIL 10 log10 10 log10
2
20 log10 ,
I1 CX 1 CX 1
4/29/2020
where
C : constant (1/ρc)
Limits of Sound Perception
Intensity/pressure of audible sound is enormous, generally 0 dB
SPL – 120 dB SPL;
4/29/2020
15
Limits of Sound Perception (cont.)
Threshold of Audibility is the acoustic intensity level of a
pure tone that can barely be heard at a particular frequency.
In other words, it is the minimum detectable level of a
4/29/2020
sound in the absence of any external sounds.
Threshold of audibility ≈ 0 dB at 1000 Hz
Threshold of feeling ≈ 120 dB
Threshold of pain ≈ 140 dB
Immediate damage ≈ 160 dB
Thresholds vary with frequency and from person-to-person.
Maximum sensitivity is at about 3000 Hz. 16
Adding Decibels
Cannot directly add dB
E.g. 72 dB + 72 dB is NOT 144 dB.
4/29/2020
Can directly add intensities (W/m2) or pressures (Pa)
E.g. 5 Pa + 5 Pa is 10 Pa and
10-7 W/m2 + 10-7 W/m2 is 2 x 10-7 W/m2.
Therefore, when adding, convert dB into W/m2 or Pa, and
add, and then convert the result back to dB.
17
Adding Decibels (cont.)
Q. The JMU music school has a brass ensemble that consists of
a trumpet (83.4 dB IL), French horn (78.1 dB IL), trombone
(85.0 dB IL), and a tuba (86.3 dB IL). What is the level of the
music when the entire ensemble is playing together?
4/29/2020
Trumpet
I
83.4 dB IL 10 log 12
10
83.4 I
log 12
10 10
I 8.34
10 12 10
I 2.19 10 4W / m 2 18
Adding Decibels (cont.)
Trumpet All together
83.4 dB IL = 2.19 x 10-4 W/m2 1.03 x 10-3 W/m2
4/29/2020
French horn (1.03 10 3 )
dB IL 10 log 12
78.1 dB IL = 6.46 x 10-5 W/m2 10
90.13 dB IL
Trombone
85.0 dB IL = 3.16 x 10-4 W/m2
Tuba
86.3 dB IL = 4.27 x 10-4 W/m2
19
Adding Decibels (cont.)
Q. You are attending an outdoor lecture held in a temporary
shelter with a tin roof. Of course, you take your sound level
meter with you. You measure the speaker at 77.3 dB IL. It
4/29/2020
then starts to rain, which makes a terrible racket. You
measure the speaker together with the rain at 78.9 dB IL.
What was the level of the rain?
4/29/2020
proportion to the inverse square of the distance from the
source. 2
I 1/ r ,
21 4/29/2020
4/29/2020
22
Inverse Square Law (cont.)
Q. Marv is standing 8 feet from a sound source and measures
a sound to be 80 dB SPL. Del is standing 32 feet from the
sound source. How many dB SPL would the sound be
4/29/2020
when it arrives at Del?
dB SPL 20 log d
Del
32 feet ? dB SPL
Marv
80 dB SPL
4/29/2020
200 feet
2 mil
es
80 dB SPL
? dB SPL
dB SPL 20log d
200
20 log 34 dB
10560
80 34 114 dB SPL
24
Assignment I
1. Given four machines producing sound pressure levels of
100 dB, 91 dB, 90 dB, and 89 dB respectively, what is the
total sound pressure level?
4/29/2020
2. If the sound pressure from a rifle shot is measured as 134
dB at 1.25 ft away, how does the sound pressure level
change at 80 ft away?
3. If the sound intensity at 3.0m away from a sound source is
4.0×10-6 W/m2, what is the intensity at (a) 1.5m and (b) 12 m
from the source?
4. Karen measures the sound intensity at a distance of 5.0m
from a lawn-mower to be 3.0×10-2 W/m2. Assuming that the
lawn-mower acts as a point sound source and ignoring the
25
effects of reflection and absorption, what is the total power
of the sound emitted by the mower?
Assignment I (cont.)
4/29/2020
sound level is 70 dB and the total intensity is 4×I1. What
are the values of I1 and L1?
6. Given a sound source 10 ft away from the receiver has an
IL of 90 dB,
(a) what is the sound intensity at the receiver?
(b) what is the sound power of the source?
(c) what is the sound IL at 80 ft from the source?
26
Lecture Contents
Part I:
What is Digital Signal Processing (DSP)?
Signal basics
4/29/2020
Systems and their properties
Sound creation and its intensity
Sound intensity in dB scale
Part II:
Analog to digital conversion
Sampling
Quantization
Encoding 27
4/29/2020
Fig. Typical annual vertical wind profile.
28
Basic Types of Signals
Discrete-time signal (x[n])
Defined only at discrete times, and consequently, the
independent variable takes on only a discrete set of
values.
4/29/2020
29
4/29/2020
sequence;
δ[n-k]=?
0, n≠k, 30
δ[n-k] =
1, n=k.
Building Block Signals
2. Unit step sequence
4/29/2020
u[n-k]=?
1, n≥k,
u[n-k] =
0, n<k.
x (t ) Ae j0t
4/29/2020
where |A| is the
magnitude of x(t), ω0
is the fundamental
frequency (radians
per second, rad/s);
32
Building Block Signals
4. Sinusoidal signals
sine and cosine signals;
important because virtually every other signals can be thought
of as being composed of many different sine and cosine
4/29/2020
signals;
to the human ear, a sound that is made of more than one sine
wave will have perceptible harmonics;
4/29/2020
Cosine
34
Phase of a Sinusoid
4/29/2020
35
Relation between Period and Frequency
4/29/2020
36
Any time-domain signals can be constructed from a
linear combination of different sinusoids.
4/29/2020
37
Beware of phase when you combine sinusoids!!!
Out-of-phase addition (Destructive)
4/29/2020
38
Beware of phase when you combine sinusoids!!!
Constructive addition
4/29/2020
39
Systems
Systems process input signals to produce output signals.
Signals contain information that can be used to explain the
underlying physiological mechanisms of a specific event or
system.
4/29/2020
Mathematical methods can be used to describe signals and to
analyze and synthesize systems.
40
Signal Energy and Power
The total energy of x(t) over the time interval t1 ≤ t ≤ t2
t2 2
x (t ) dt , where |x(t)| means magnitude of complex number x(t);
t1
4/29/2020
1 t2 2
The time-averaged power is x (t ) dt
t 2 t1 t1
x[n]
2
, where |x[n]| means magnitude of complex number x[n];
n n1
n2
x[n]
The time-averaged power is 1 2
n2 n1 1
, 41
n n1
Linear Systems
A linear system, in continuous time or discrete time, is a
system that possesses the important property of superposition.
Homogeneity
Modification in the input signal’s amplitude results in a
4/29/2020
corresponding modification in the output.
T{x(t)} = y(t)
T{ax(t)} = ay(t)
Additivity
For any two inputs, the sum of the outputs is the same as if
the sum of the two inputs had been processed together.
T{x1(t)} = y1(t), T{x2(t)} = y2(t)
T{x1(t) + x2(t)} = y1(t) + y2(t)
42
Superposition
Continuous time: ax1(t) + bx2(t) = ay1(t) + by2(t)
Discrete time: ax1[n] + bx2[n] = ay1[n] + by2[n]
Practice on Linear Systems
y ( t ) tx ( t )
For x ( t ), y ( t ) tx ( t )
1 1 1
For x ( t ), y ( t ) tx ( t )
2 2 2
For x ( t ) ax ( t ) bx ( t ),
4/29/2020
3 1 2
y ( t ) tx ( t ) t [ ax ( t ) bx ( t )]
3 3 1 2
y ( t ) ay ( t ) by ( t )
3 1 2 2
y (t ) x (t )
The system is linear.
2
For x ( t ), y ( t ) x ( t )
1 1 1
2
For x ( t ), y ( t ) x ( t )
2 2 2
For x ( t ) ax ( t ) bx ( t ),
3 1 2
2 2
y ( t ) x ( t ) [ ax ( t ) bx ( t )] 43
3 3 1 2
y ( t ) ay ( t ) by ( t )
3 1 2
The system is not linear.
Time Invariant Systems
A system is time-invariant if a time-shift/delay of the input
sequence causes a corresponding shift/delay in the output
sequence.
T{x(t)} = y(t)
4/29/2020
T{x(t-t0)} = y(t-t0)
4/29/2020
1. A very important way to analyze an LTI system is to study
the output signal when a unit impulse signal is used as an
input.
Impulse response
4/29/2020
the system’s impulse response h[n].
46
Convolution Illustration (cont.)
4/29/2020
47
Ref: wikipedia
Convolution (cont.)
Drawback of convolution in time domain
Convolution is NOT a simple multiplication. Each
output instance y is the SUM of x multiplied with h
4/29/2020
with all time offsets.
A very simple and time-effective way of performing the
convolution process is using the Fourier Transform.
The Fourier transform of the convolution is the product of
the two Fourier transforms! − The Convolution Theorem
48
Assignment II
4/29/2020
(a) y ( t ) x (t 2 )(b) y (t ) x (t 2)
49
Lecture Contents
Part I:
What is Digital Signal Processing (DSP)?
Signal basics
4/29/2020
Systems and their properties
Sound creation and its intensity
Sound intensity in dB scale
Part II:
Analog to digital conversion
Sampling
Quantization
Encoding 50
4/29/2020
samples you take, the more accurate the representation is;
2. Quantization
replaces amplitude at sampling instant with an approximation
from a finite set of discrete values (levels);
bit depth >>> no. of bits used to encode a discrete value;
n-bit bit-depth-> 2n levels
Encoding ( digital signal)
converts each discrete value into a discrete binary number with
a specified bit-depth; 51
the higher the bit-depth, the larger the file size but the better the
signal resolution;
x[n] = {6.5, 3.3, 2.0, 2.5, 4.4, 5.0, 3.7, 2.2, 2.0}
4/29/2020
3-bit quantization bit-depth
52
52
Sampling
Sampling converts an analog signal into a series of impulses,
each representing the amplitude of the signal at a given
instance in time.
A discrete-time signal x[n], can be typically obtained by
4/29/2020
periodic sampling of a continuous-time signal xc(t).
4/29/2020
an accurate representation of the original continuously moving scene.
Example 2 Bouncing Ball
If a ball is photographed (sampled) at one instant during a single
bounce, you cannot tell anything about the path of the ball except that
it is off the floor. You can’t tell whether it is going up or down or the
distance of its bounce. If you take more photos at equally-spaced
instants during one bounce, the more accurately you can determine the
path of the ball as it bounces.
55
The Sampling Theorem
4/29/2020
Q. A continuous-time signal xc(t) is sampled at fsample = 8 kHz to
obtain a discrete-time signal x[n]. If the xc(t) is uniquely
recoverable from x[n], what is the highest frequency of xc(t)?
Ans. 4 kHz 56
Aliasing & Anti-aliasing Filter
Aliasing occurs when the sampling frequency is not at least twice the
signal frequency.
If an analog signal contains frequencies above the Nyquist frequency,
these frequencies overlap into the spectrum of the sampled signal and
4/29/2020
interference occurs. This unwanted condition is known as aliasing.
An alias is a signal which has a frequency that is less than the highest
frequency in the analog signal being sampled and thus falls within
the spectrum or frequency band of the input analog signal causing
distortion.
Low-pass filtering is necessary to remove all frequency components
of the analog signal that exceed the Nyquist frequency.
Aliasing can also be avoided by sufficiently increasing the sampling
frequency.
E.g. If a sound signal is not sampled at a high enough rate, the effect 57
of aliasing will become noticeable with background noise and
distortion.
Assignment III
4/29/2020
uniquely recoverable from x[n], what is the possible highest
frequency of xc(t)?
58
Quantization
The process of mapping a large set of input values (real numbers) to
an approximation from a finite set of discrete values (levels);
n-bit bit-depth-> 2^n levels;
bit depth = no. of bits used to encode a discrete value;
4/29/2020
the higher the bit-depth, the more accurate the representation;
Rounding and truncation are typical quantization processes.
Forms the core of all lossy compression algorithms.
4/29/2020
1
0
Fig. Bit-depth = 4.
60
Fig. Bit-depth = 4 (± values).
Importance of Bit-Depth Two-bit quantization
Just an example
4/29/2020
Reconstructed
61
Four-bit quantization
4/29/2020
The higher the bit-depth,
the more accurate the
representation;
62
Quantization Noise/Error
Quantization is an irreversible process (i.e., the same output
value is shared by multiple input values but it is impossible in
general to recover the exact input value.)
Quantization noise/error is the difference between the actual
4/29/2020
value and the quantized value.
63
Bit-Depth vs. Quantization Noise
The higher the bit-depth, the less the quantization noise and the
better the signal resolution, but the larger the size of the
encoded signal will be. (the less compression ratio)
4/29/2020
64
Recap: What is DSP?
Represent signals by a sequence of number
Sampling or analog-to-digital conversions
Perform processing on these numbers with a digital processor
Digital signal processing (DSP)
4/29/2020
Reconstruct analog signal from processed numbers
Reconstruction or digital-to-analog conversion
digital digital
analog signal signal analog
A/D DSP D/A
signal signal
65
4/29/2020
66
Application Areas
Audio Segmentation
Segmenting of audio stream into speech, music or silence
Audio Classification
Classifying an audio stream into different sound classes
Audio Indexing
4/29/2020
To facilitate effective management and use of enormous
amounts of audio data
Audio Watermarking
To prevent unauthorized copying and distribution
Audio Coding
To obtain compact digital representations of high fidelity
audio signal
Music Summarization
To generate a concise and informative content that best
summarizes an original content;
Music indexing, content-based music retrieval and web- 67
based music distribution;
Emotion classification
Application Areas
Electrocardiogram (ECG)
Electrical activity of heart
Detection of ECG waveform components
Segmentation
4/29/2020
Heart beat type classification
Phonocardiogram (PCG)
Heart sounds vibrations
Segmentation
Detection and classification
Electromyography (EMG)
Human muscle movement
Muscle activity detection
Electroencephalogram (EEG)
Summation of the electrical activity caused by the random
firing of neurons in brain 68
References
[1] Alan V. Oppenheim, Alan S. Willsky, and S. Hamid Nawab,
Signals & Systems, Second Edition, Prentice Hall, 1996.
[2] Thomas L. Floyd, Chapter 12: Signal Conversion and
Processing, Digital Fundamentals, Global Edition, Pearson, 2015.
4/29/2020
69
4/29/2020
Thank YOU!!!
70