100% found this document useful (1 vote)
20 views

Signal Processing Assignment Help

Get Best Signal Processing Assignment Help
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
20 views

Signal Processing Assignment Help

Get Best Signal Processing Assignment Help
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

To get more info, Please Contact Us : – +1 678 648 4277

Visit : – https://www.matlabassignmentexperts.com/
E-Mail : – [email protected]
Signal Processing Assignment Help
Problem 1:
A Mini-project: An Audio Scrambler. Text-messaging is out-of-date! You and I have
been communicating by sending voice-messages to each other as “.wav” files. It’s not
that I am paranoid, but everybody is out to get me! In particular, “they” have been
intercepting all of our voice messages. But we are going to outwit “them” by using
MATLAB to scramble our voice messages before sending them, making them
unintelligible using a secret encoding scheme, and then we will descrambling the
messages when we get them. your task is to design and implement the speech
encoder and decoder. the requirement is that the scrambled message should occupy
the same audio bandwidth (approximately 300 – 3000 Hz) as the original message,
and the descrambled message should have good fidelity. We will use a frequency
domain “mirroring” scheme, where the frequency components are flipped, so that
high frequencies are translated to low frequencies and vice-versa. A spectral com­
ponent with frequency Ω1 will be translated to a new frequency Ωa − Ω1 , where Ωa is
known to the sender and recipient. The resulting waveform is unintelligible until the
frequency relationships have been restored. The scheme is shown below:
F   F  j( a
j 
  
s c ra m
b le

o rig in a s c ra m b le d
l s p e e c sp e e c h

Thus, a spectrum as shown on the left will be translated to that shown on the
right. The decoder will restore the correct frequency relationships.
Consider a component A sin(Ωt), we want to translate it to A sin ((Ωa − Ω) t).
From elementary trigonometry A sin ((Ωa − Ω) t) = A (sin(Ωat) cos(Ωt) −
cos(Ωat) sin(Ωt)) = A sin(Ωa t) sin(Ωt + π/2) − A sin(Ωa t + π/2) sin(Ωt)
which leads to the following time-domain processing to shift a single frequency
component.
A π/2 phase-shifter is easy to build for a single frequency, such as sin(Ωat) but
when the input signal, such as a speech signal, contains more than just a single
component each spectral component must be shifted by 90 ◦. This requires an all-
pass filter with a constant phase shift, which is a difficult design task for a
continuous filter. Approximations as active or passive filters are available.
The Hilbert transformer is an all-pass filter with a transfer function

which is exactly what we want. The following shows the scrambler implemented
with a Hilbert transformer

Then G(jΩ) = F(j(Ωa − Ω).


(a) Practical implementations of Hilbert transformers are approximations. For
example, suppose an implementation has ripple in its passband so that at a
particular frequency Ωo the transfer function is

where δ is a perturbation from the ideal response. Find the output g(t)
when the input is f (t) = A sin(Ωot). Have any “spurious” spectral
components been introduced? (You can do this with simple trigonometric
identities.)
(b) Your task is to design, implement, and test an audio scrambler and
descrambler using this encoding technique:
• You should write a pair of MATLAB functions as follows:
y_scramble = encode(f_audio, Fs, Fa)
y_descramble = decode(y_scramble, Fs , Fa)
where f audio is a MATLAB array containing the audio file to be processed, Fs
is the sampling frequency (Hz) of the data in f audio, and Fa is the frequency
(Hz) around which the spectrum is reflected. The first function should take
encode the file, the second restore the scrambled version to the original.
• We will supply you with two audio files (.wav) that you can download and
use. One is an ordinary audio file (PS8Raw.wav) that is to be to be scrambled
and descrambled. The second is one that π we have already scrambled
(PS8Scrambled.wav). These may be imported into your MATLAB workspace
using the wavread() function
[f_audio,Fs,Nbits] = wavread(’myfi le’)
see the MATLAB help.
• You should use the Parks-McClellan design function fi rpm() to design a Hilbert
trans­ former that covers the frequency span 300 – 3000 Hz. (The help on
fi rpm() has an example) Be aware that the quality of you scrambling will be
affected by the pass-band ripple that you allow.
• Don’t forget that the FIR Hilbert transformer is a causal linear-phase
system, and that it MUST have an odd length impulse response. You will need
to add an equivalent delay filter in the other arm. Design an appropriate FIR
impulse response.

• The audio arrays will be large. Use fft fi l t ( ) to do the actual filtering
operations.
• Let’s standardize on a reflection frequency F a = 3500 Hz.
• To test your scrambler, load the audio file, then compute and plot its
magnitude spec­ trum. Then scramble the file and plot its magnitude
spectrum. Make sure it is what you expect. If there are any spurious
components, try to find why they are there, and fix them.
You should submit the following:
(a)Listings of your two functions.
(b) Details of your Hilbert transformer design, including plots of the pass-
band ripple, and details of the phase response.
(c)A summary of your approach, including the compromises you made in any
design choices.
(d)Plots of the magnitude spectra of
1. The audio file in PS8Raw.wav.
2. Your scrambled version of PS8Raw.wav.
3. The result of descrambling your scrambled version of
PS8Raw.wav. Use fft s h i ft ( ) on the spectra to make them
more readable.
(e)You should upload three .wav files to the 2.161 MIT Server site in
the homework section:
1. Your scrambled version of PS8Scrambled.wav.
2. Your descrambled version of PS8RawScrambled.wav.
3. The result of scrambling then descrambling PS8Raw.wav.
Be sure to name the files so that they are clearly identified
as yours...
We will be available to help if you run into trouble.
Problem 2: An analog integrator has a transfer function H(s) = 1/s. Use the
bilinear transform to find (a) the discrete time transfer function H(z), and (b)
the difference equation for this form of digital integrator.
Plot the frequency response functions of the resulting digital integrator.
Problem 3: A continuous band-pass filter is described by the transfer
function

Derive a recursive computing formula (difference equation) for (1) a step-


invariant, (2) a root matching, and (c) a bilinear transform digital filter based
on this system. Assume Δ T = 0.1s.

Problem 4: A digital filter is to be designed to the following specifications:


(a)What is the order of the continuous filter if a Chebyshev design is used.
(b) Prewarp the critical frequencies to find the equivalent frequencies for use in
the bilinear trans­ form with a sampling frequency of 50,000 samples/sec.
(c) Use MATLAB to design a continuous Chebyshev Type 1 filter with the
prewarped crical frequencies. Then use the b i l i ne a r( ) function to compute
the discrete time transfer function from the continuous prototype.
(d)Make frequency response and pole-zero plots for your resulting filter.
(e) Use MATLAB to convert the prototype design to a band-pass digital filter
with a passband of 5-15 kHz.

.
Solutions
Problem 1:
The standard Hilbert transformer is defined as:

M ATLAB uses the same definition and this can be verified by finding the phase of
ω → 0 + . The implemented filter’s phase has a linear component added to the
−π/2 value (for ω > 0).
Our filter has −π/2 phase shift and this corresponds to:

A sin ((Ω a − Ω) t) = A (sin(Ω a t) cos(Ωt) − cos(Ωa t) sin(Ωt))


= −A sin(Ω a t) sin(Ωt − π/2) − A cos(Ω a t) sin(Ωt)
We have to be careful in implementing the scrambler. The scrambler diagram
corresponds to the below figure. However, note that the audio play is not
affected by sign of output (i.e. a signal is played the same as its negative
version).

(a) The delay in implementation does not affect this discussion. So we ignore it for
this analysis. We consider a sinusoidal component of input as f(t) = sin(Ωot). The
output of filter would be |H(jΩo)|sin(Ωot+6 H(jΩo)) = (1+δ)sin(Ωot− π 2 ). We
follow this through above diagram to compute g(t):
As a result due to practical implementation, some “spurious” components are
introduced at Ωa + Ωo .
The original signal has a (desired) audio frequency content of Ωo = 300 − 3000
Hz. In the beginning, we can pre-process the audio file with a band-pass filter
passing 300 − 3000 Hz contents and then follow it with the scrambling
process.
We use a Hilbert transformer with a pass-band equal to 300 to (F s /2 − 300)
Hz, where F s is the sampling frequency . The extended pass-band of the filter, is
because a high-order (low-ripple) “firpm-built” Hilbert filter requires a
symmetric pass-band (see M ATLAB doc­ umentation). After passing the audio
file through our transformer with Ωa = 3500 Hz, the output will have a large
(desired) spectrum content at 500 − 3200 Hz and a spurious content at 3800 −
6500 Hz (which could be folded to some lower frequency). If δ is not small
enough, we might wish to post-process the filter output with a pass-band filter
passing 500 − 3200 Hz contents and then save it as scrambled signal. This
post processing step of scrambling, can be considered as a pre-processing step
of desrcambling procedure.

Theoretically, descrambling is the same as scramblibg. However, the


practical realization of the Hilbert filter is bandwidth limited (while the ideal
Hilbert filter is an all-pass filter). The Hilbert Filter for desrcambling, requires a
pass-band equal to 500 to (F s /2 − 500) Hz. However, if we pre-process the
srcambled signal with a pass-band filter passing 500 − 3200 Hz contents,
then we can use the same Hilbert filter for scrambling and descrambling. The
output of desrcambling can be further post-processed with a pass-band filter
passing audio contents (300 − 300 Hz).
(b) This is not the complete solution to all parts of the problem. This simply
serves to show the approach. To study the full solution start with attached
Main.m file and follow other scripts. Note that the encoding and decoding
functions can be identical (if we use proper pre/post filters). Here is the
encoding script:

functi on fout = encode(fi n,Fs,Fc)

%% Design the Hilber transformer


% Note: fi rpm() seems to need the band edges to be symmetric
about 0.5 h1=firpm(150,[300*2/Fs 1-300*2/Fs],[1
1 ] ,’ H i l b e r t ’ ) ;
% h1=firpm(150,[500*2/Fs 1-500*2/Fs],[1 1 ] ,’ H i l b e r t ’ ) ; % change in the
decode fi l e y 1 = fft fi l t ( h 1 , fi n ) ;

%% Delay: Approach 1
N=length(h1); %N i s odd
y2=zeros(size(fi n));y2((N-
1)/2+1:end)=fi n(1:end-
(N-1)/2);
%% Delay: Design the
delay fi l t e r, Approach 2
% h2 =
zeros(1,length(h1));
% h2((N-1)/2+1) = 1;
% F i l t e r the data
% y 2 = fft fi l t ( h 2 , fi n ) ;
%% F i l t e r Output
t=(0:length(fi n)-1)*(1/Fs);
y3=-y1.*sin(2*pi*Fc*t ’);
y4=-y2.*cos(2*pi*Fc*t ’);
fout= y3+y4;

The following graph shows one the encoder’s


Hilbert transformer (order 150).
Encoder Hilbert Filter
s for F
5
=11.025 KHz
0
Magnitude

−5

−10
(dB)

−15

−20
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency (
rad/sample)
0

−5000
(degrees)
Phase

−10000

−15000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)

We passed the input original audio through a band-pass filter (300-3000 Hz) to
minimize the folding of high frequencies. We used the same filter for the
decoder output. We also used a band pass filter (500-3200 Hz) for the encoder
output or for the decoder input. These pass-band filters are implemented as a
series of low and high pass filters (all order 200). Otherwise, we could not build
a nice pass band filter in a single step. All these filters are shown on the next
page
Note that following the original signal through all filters (audio filter, Hilbert,
pre-decode, Hilbert and audio filter), results in a delay equal to 750 samples ( 3
∗ (200/2 + 200/2) + 2 ∗ (150/2) ). Although 750 might be a large number, but
even for our lowest F s = 11.02 KHz, this means less then 0.07 second delay. This
small delay is hardly noticeable by our hearing system and hence our filter’s
orders are not too large.
Audio Filter (Post−Decoding or
20 Pre−Encoding)

−20
Magnitude

−40
(dB)

−60

Low Pass: Fs=11.025 KHz


−80 High Pass: Fs=11.025 KHz

Low Pass: Fs=22.05 KHz


High Pass: Fs=22.05 KHz
−10
−16
0
0 200 400 6000 800 100
0
0 0 Frequency 0 00
−12 (Hz)
Post−Encoding
20 (Pre−Decoding) Filter
0
−14
00

−2
0
Magnitude
(dB)

−4
0
−10 Low Pass: Fs=11.025
0 High Pass:
KHz
−12 Fs=11.025 KHz
−6
00 Low Pass:
−14 Fs=22.05 KHz
0 High Pass:
−16
−80
200 400 6000 Fs=22.05
800 KHz 100
0 0
0 0 Frequency 0 00
(Hz)

The following plots resulted from working on


PS8Raw.wav:
(3): Magnitude Spectrum of Encoder Output
4500

4000

3500

3000

2500

2000

1500

1000

500

0
−5000 −4000 −3000 −2000 −1000 0 1000 2000 3000 4000 5000
Frequency (Hz)

Magnitude Spectrum of Decoder Input (After


(4):
Decoder Fitler)
4000
4500
3500

3000

2500

2000

1500

1000

500

0
−5000 −4000 −3000 −2000 −1000 0 1000 2000 3000 4000 5000
Frequency (Hz)
(5): Magnitude Spectrum of
Decoder Output
4500

4000

3500

3000

2500

2000

1500

1000

500

0
−5000 −4000 −3000 −2000 −1000 0 1000 2000 3000 4000 5000
Frequency (Hz)

(4): Magnitude Spectrum of Decoder Input (After Decoder Fitler)


(6): Magnitude Spectrum of Audio Fitered Decoder Output
4500

4000

3500

3000

2500

2000

1500

1000

500

0
−5000 −4000 −3000 −2000 −1000 0 1000 2000 3000 4000 5000

Frequency (Hz)

Comparing the input and decoded spectra shows them to be the same. In your
solutions, we will be looking for stray spectral components that may result from
ripple in your Hilbert transformer response etc.
Problem 2: (a) If H(s) = 1/s, then the bilinear transform (using Tustin’s approximation)
gives:

(b) From above

which is the trapezoidal numerical integration rule.


The following MATLAB commands generate the frequency
response:
b = [0.5 0.5];
a = [1 -1];
freqz(b,a)
title(’Bilinear Integrator’)
Note that while the phase is constant at −π/2, the magnitude plot does not show
a constant slope of -20 dB/decade as does the analog integrator.

Problem 3:
(a) The plant

has (1) a zero at s = 0, and (2) a pair of coincident poles at s = −1. The root-
matching (matched z-transform) discrete-time system is

and with T = 0.1 sec.,


To create a minimum delay filter, make the order of the numerator and
denominator equal by adding a zero at the origin:

The gain factor K must be determined empirically. This is normally done using the
finalvalue theorem, but in this case lims→0 H(s) = 0 and the final values cannot be
compared. Some other amplitude criterion must be used; in this case the peak
value of the two step responses were compared and found to be 0.367 for the
continuous system H(s) and 4.018 for the discrete system H(z). Then K =
0.367/4.018 = 0.0913.

Alternatively you might compare the response of the analog system to a ramp
input r(t) = t with the analogous discrete response to a ramp rn = 0.1n and use
their final values to match the gains resulting in K = 0.097. The step responses with
K = 0.0913 are compared in the plot below
Note the slight delay in the digital response.
(b) The system has repeated poles at s = −1. Then H(s) may be expressed in partial
fractions as

and

As we discussed in class, this form of impulse invariant simulation suffers from a


gain error, and a correction

is more frequently used. The step responses of H(s) and H ′ (z) are compared in
the following plot.
and we note:
• The final value is incorrect (due to aliasing in the transfer function), and
• Further empirical gain adjustment is necessary to match the peak responses.

(c) With the bilinear


transform
The step responses of H(s) and H(z) are compared in the
following plot.

Bilinear Simulation − Step


Response
0.4
bilinear
0.35

continuous
0.3

0.25

0.2

0.15

0.1

0.05

0
0 2 4 6 8 10

The frequency response of these three discrete approximations of our continuous


filter, are plotted and compared to the frequency response of the continuous
filter in the next page. In general, root matching and impulse invariant filters are
approximately the same and show almost exactly the same curves.
The magnitude plot shows that below 1 Hz, all of the three filters match very
well with the continuous filter. However as the frequency increases toward the
Nyquist frequency the bilinear filters deviates strongly from the continuos filter
and the two others almost follow the continuos curve.
On the other hand, in the phase plot, the bilinear filter almost exactly matches
the continuos filter, while the two others deviate strongly from the continuous
filter and only match it at very low frequencies (i.e. below 0.3 Hz).
0
Root matching
Impulse Invariant
−10
Bilinear
Continuous
−20
Magnitude (dB)

−30

−40

−50

−60

−70
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

Frequency
(Hz)

80
Root matching
60 Impulse Invariant
Bilinear
40 Continuous

20
Phase (degrees)

−20

−40

−60

−80
−100
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Frequency
(Hz)

Problem 4:
(a) From the specifications

For a continuous filter (no pre-


warping)
Therefore take N = 4.
(b) In the pre-warped analog filter the critical
frequencies will be

and the order is given by

Therefore take N = 3.

(c) MATLAB gave me a lot of problems with ill-conditioning while trying to do this! I
had to scale the sampling rate back – for example by a factor of 100, to 500
samples/sec.:
(d) The pole-zero plot and frequency response plots are shown
on the next page.

0.8

0.6

0.4
Imaginary Part

0.2
3
0

−0.2

−0.4

−0.6

−0.8

−1
−1 −0.5 0 0.5 1
Real
Part

0
Magnitude (dB)

−50

−100

−150
0 0.5 1 1.5 2 2.5

Frequency (Hz) x 10
4

−50

−100
Phase (degrees)

−150

−200

−250

−300
0 0.5 1 1.5 2 2.5

Frequency x 10
4

(Hz)
(e) We have to pre-warp the band limits to use them in converting the prototype
continuous low pass filter (with cut-off frequency of 1 rad/sec) to our prototype
continuous band pass filter.

20

0
X: X:
−20
5000 1.5e+04
−40 Y: −3 Y: −3

−60
Magnitude (dB)

−80

−100

−120

−140

−160

−180

−200
0 0.5 1 1.5 2 2.5
Frequency (Hz) 4
x 10

−100

−200
Phase (degrees)

−300

−400

−500

−600

−700
0 0.5 1 1.5 2 2.5
Frequency (Hz) 4

T = 1/500;
x 10

wc1 =
2*pi*50;
wc2 =
2*pi*150;

wc1_p =
(2/T)*tan(wc1*T/2);
wc2_p =
(2/T)*tan(wc2*T/2);

[ b , a] = cheby1(3, 3, 1 ,’s ’ ) ; % Design LP with


wc=1 rad/sec
[b,a]=lp2bp(b,a,sqrt(wc1_p*wc2_p),(wc2_p-
wc1_p)); %Change to BP [bz,az ] = bi l i nea r(b, a ,
500);

You might also like