Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
DSP_Filters_150505.pptx
1. Beirut Arab University
Computer Engineering Program
Spring 2015
Digital Signal Processing (COME
384)
Instructor: Prof. Dr. Hamed Nassar
Filters (Chapter 6)
Textbook:
◦ V. Ingle and J. Proakis, Digital Signal Processing Using
MATLAB 3rd Ed, Cengage Learning, 2012
1
Dr. Hamed Nassar, Beirut Arab Univ
3. Digital Filters: FIR and IIR
We will now use the theory of discrete systems that we
have studied to process of digital signals, which is carried
out using systems called filters (or spectrum analyzers in
some contexts).
The filter design is influenced by such factors as the type
of the filter (IIR or FIR) or the form of its implementation
(structures).
Hence, before we discuss the design issue, we look at
how these filters can be implemented in practice.
This is an important concern because different filter
structures dictate different design strategies.
IIR filters as designed and used in DSP, can be modeled
by rational system functions or, equivalently, difference
equations.
Such filters are termed autoregressive moving average
(ARMA) or, more generally, as recursive filters.
Prof. H. Nassar, BAU
5. Three Building Blocks
Our filters are LTI systems, and thus we need only the
following three elements to describe their structures.
◦ 1. Adder: This element has two inputs and one output
and is shown in Figure 6.1a. Note that the addition of
three or more signals is implemented by successive
two-input adders.
◦ 2. Multiplier (gain): This is a single-input, single-output
element and is shown in Figure 6.1b. Note that the
multiplication by 1 is understood and hence not explicitly
shown.
◦ 3. Delay element (shifter or memory): This element
delays the signal passing through it by one sample, as
shown in Figure 6.1c. It is implemented by using a shift
register.
Using these basic elements, we can now describe various
structures of both IIR and FIR filters.
MATLAB is a convenient tool in the development of these
Prof. H. Nassar, BAU
6. IIR FILTER STRUCTURES: 3 types
Three different structures can be used to implement IIR
filters:
◦ 1. Direct form: DE (6.2) is implemented directly. As it has two parts:
the moving average part (numerator) and the recursive part
(denominator), this implementation leads to two versions: direct
form I and direct form II.
◦ 2. Cascade form: H(z) in (6.1) is factored into smaller 2nd-order
sections, called biquads, and each biquad is implemented in a
direct form, and the entire system function is implemented as a
cascade of biquad sections. Prof. H. Nassar, BAU
9. MATLAB IMPLEMENTATION
In MATLAB the direct form structure is implemented by the
built-in function filter whose syntax is:
Y = FILTER(B,A,X)
where B and A are vectors representing the the filter
paramters (B containing the {bn} coefficients and A
containing the {an} coefficients) of the filter’s difference
equation, which for M=N=4, takes the form:
.
Prof. H. Nassar, BAU
10. Echo Generation
The most basic of all audio effects is that of time delay,
echoes.
Echo used as building block of complex effects, e.g. reverb &
flanging.
For example, the combination of the direct sound
represented by discrete signal y and a single echo
appearing D samples later (which is related to delay in
seconds) can be generated by the (difference) equation
(assuming x = input and y = output)
y(n)= x(n)+ αx(n − D), |α| < 1
where y is the resulting signal and α the attenuation.
Difference equations are implemented in MATLAB using
the filter function Y = FILTER(B,A,X)
Thus, we will use here A=1 (coeff of output signal y(n))
Prof. H. Nassar, BAU
11. An Audio application of DSP: adding & removing echo
DSP has applications audio and video. Here we add echo.
%MA_SoundEcho.m: Add and remove echo from a sound piece.
%9 s of Handel's Halleluja sampled at 8192 sam/sec. It is in file:
handel.mat.
%We'll play it with echo delayed by D = 7196 samples, i.e 0.9 s
load handel; %Place signal in vector y & sampling freq in
var Fs
sound(y,Fs); % Play signal y with the sampling frequency
Fs
pause(5);
alpha = 0.9; D = 7196; %Attenuation=alpha, Delay=D
samples
b= [1,zeros(1,D),alpha]; % Filter parameters (coffs of x in
DE)
x= filter(b,1,y); % Place sound+echo piece in vector x
sound(x,Fs); %Play sound+echo at frequency Fs
Prof. H. Nassar, BAU
12. Sound script Instructions
LOAD Load data from MAT-file into workspace. The
samples go into a vector named y and the sampling
frequency goes to a variable named Fs (both can be
displayed into MATLAB’s workspace by writing their
names).
SOUND(y,Fs) Sends the signal in y at the rate specified in
Fs (both initialized during file ‘load’ above) out to the
speaker. Values in y are assumed to be in the range -1.0
<= y <= 1.0; those outside that range are clipped.
Y = FILTER(B,A,X) filters the data in vector X with the filter
described by vectors A and B to create the filtered data Y.
The filter is a "Direct Form II Transposed“ implementation
of the standard difference equation:
a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-
nb)
- a(2)*y(n-1) - ... - a(na+1)*y(n-na)
Prof. H. Nassar, BAU
13. Echo Removal
After executing this simulation, you may experience that
the echo is an objectionable interference while listening.
Again DSP can be used effectively to eliminate echoes.
Given that w is the signal with echo, we can produce from
it a signal x without echo as follows:
w[n]+ αw[n − D]= x[n] (1.3)
where w[n]is the echo-corrupted sound signal and x[n] is
the output sound signal, which has the echo (hopefully)
removed.
In MATLAB, this is equivalent to reversing the coefficients
A and B. Now the following MATLAB script on the echo-
corrupted signal w[n].
x= filter(1,b,w);
sound(x,Fs)
Prof. H. Nassar, BAU
14. Further Processing of Audio Signal
When we load an audio signal, such as ‘Handel’, into
MATLAB with the ‘load’ function, the signal goes by default
to a vector named ‘y’, and the sampling frequency goes to
a variable named ‘Fs’
Besides the echo addition/removal which we can do using
the ‘filter’ function, as we have demonestrated, we can
directly process the signal ‘y’ itself on MATLAB using the
techniques we have learned in the course: scale it up or
down, shift it right or left, delete part of it, copy part of it
into another part, etc.
You are encouraged to practice with the audio pieces that
come with MATLAB, e.g. handel.mat and gong.mat.
Prof. H. Nassar, BAU