Signal Processing Assignment Help
Signal Processing Assignment Help
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
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
.
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) 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.
%% 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;
−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
−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)
4000
3500
3000
2500
2000
1500
1000
500
0
−5000 −4000 −3000 −2000 −1000 0 1000 2000 3000 4000 5000
Frequency (Hz)
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)
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:
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
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
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.
continuous
0.3
0.25
0.2
0.15
0.1
0.05
0
0 2 4 6 8 10
−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
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);