Lab #05
Lab #05
Download
Impulse Response
The impulse that is referred to in the term impulse response is generally a short‐duration time‐domain
signal. In discrete‐time systems, the Kronecker delta function δ[n] is typically used.
A system's impulse response (often annotated as h[n] for discrete‐time systems) is defined as the output
signal that results when an impulse is applied to the system input.
[1]
Properties of Stable LTI Systems
x1 H y1
x=x1+x2 H y=y1+y2
x2 H Y2
If this linear system is time invariant, delaying the input should produce the same response.
Reference: http://www.ling.upenn.edu/courses/cogs501/ImpulseResponse.html
Convolution
Convolution is a mathematical way of combining two signals to form a third signal. It is the single most
important technique in DSP. Convolution is important because it relates the three signals of interest: the
input signal, the output signal, and the impulse response.
[2]
Task#1
7. Shift h.
x 3 4 5 6
h 2 1
Answer
3 4 56
h I 2
conv x h
[3]
Task#2
Unfortunately, the convolution process can involve excessive computational resources. Another
efficient form of known convolution process is the “frequency domain convolution process”. In
other words, convolving signals in time domain is equivalent to multiplying their Fourier
transforms in frequency domain. Thus, what appears to be a complicated operation in time, is
simple if viewed in terms of frequency.
x(n)∗h(n) = X(ω).H(ω)
4
n fft x 6
An fft y 61
¼ in
Show this concept with x=[1 2 3] and y=[4 5 6]
Task#3: Applications of Convolution » Filtering
In this scenario, two signals are added, a low‐frequency ramp signal and a high‐frequency sine
wave. The compound signal is then processed with a moving average filter using convolution.
Design steps
1. Generate a 5 Hz sine waveform with T=10 and Fs=50 Hz.
2. Generate a ramp signal. The size of the ramp = number of samples in previous signal.
Scale the amplitude to 1.
3. Generate the input signal (x) by adding the two previous signals.
4. Get the impulse response of a 10‐point moving average filter, h. where:
b = 0.1 + 0.1z-1 + 0.1 z-2 + …… +0.1z-9 , a = 1
5. Convolute x and h.
6. Plot filter’s I/O.
7. What is the result of this convolution?
Input
0.8
0.6
0.4
0.2
0
0 100 200 300 400 500 600
[4]
f=5; T=10; Fs=50;%dt=1/Fs
t=0:1/Fs:T-1/Fs;
%sin wave g
x1=0.2*sin(2*pi*f*t)
gure
plot(t,x1);
%ramp signal g
N=length(x1);
step=1/N;
n=0:N-1;
x2=step*n;
gure
plot(t,x2);
%3 genrate the input signal(x) by adding the two pervious signals
x=x1+x2;
gure
plot(t,x);% ramp and sin signal
%4. get the impulse response of a 10-point moving average lter
%b = 0.1 + 0.1z -1 + 0.1 z -2 + …… +0.1z -9 , a = 1
a=1;
b=0.1*ones(1,10); % you can do it as [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]
h=b;
%5. convolute x and h.
y=conv(x,h);
%6.plot lter's I/O.
gure
plot(y);
%7.the result is ltered signal
Task#4: Applications of Convolution » Reverbing
The convolution process can be utilized to equalize or add spatial components to the audio
input signal to add “color” to the input signal.
An impulse response is a recording of the reverberation that is caused by an acoustic space
when an ideal impulse is played. However, an ideal impulse is a mathematical construct, and
cannot exist in reality, as it would have to be infinitesimally narrow in time. Therefore,
approximations have to be used: the sound of an electric spark, starter pistol shot or the
bursting of a balloon, for instance.
Design steps
1. Open hello.wav file and extract the 1D array
2. Open the clap2.wav and extract the 1D array
3. Convolve the two arrays
4. Re‐build the waveform of the convolved signal.
5. Play the new signal
6. What is the result of this convolution?
Correlation
Correlation is the optimal technique for detecting a known waveform in random noise. That is,
the peak is higher above the noise using correlation than can be produced by any other linear
system (To be perfectly correct, it is only optimal for random white noise).
The concept of correlation can best be presented with an example. Figure below shows the key
elements of a radar system. A specially designed antenna transmits a short burst of radio wave
energy in a selected direction. If the propagating wave strikes an object, such as the helicopter
in this illustration, a small fraction of the energy is reflected back toward a radio receiver
located near the transmitter.
[5]
y1,Fs1] = audioread('hello.wav')
info1= audioinfo('hello.wav')
figure,plot(y1)
sound(y1,Fs1)
[y2,Fs2]= audioread('clap2.wav')
info2=audioinfo('clap2.wav')
fs1=info.SampleRate
fs2=info2.SampleRate
figure,plot(y2)
sound(y2,Fs1)
% resample to match Fs
x=Fs1/Fs2;
[N,D]=rat(x)
y2n=resample(y2,N,D)
sound(y2n,Fs1)
%3. convolve the two arrays
y=conv(y2n,y1);
%4. re-build the waveform of the
convloted signal
figure,plot(y)
%5. play the new signal
sound (y,Fs1)
% 6. what is the result of this convolution
The transmitted pulse is a specific shape that we have selected. The received signal will consist
of two parts: [1] a shifted and scaled version of the transmitted pulse, and [2] random noise,
resulting from interfering radio waves, thermal noise in the electronics, etc.
Since radio signals travel at a known rate, the speed of light, the shift between the transmitted
and received pulse is a direct measure of the distance to the object being detected.
This is the problem: given a signal of some known shape, what is the best way to determine
where (or if) the signal occurs in another signal. Correlation is the answer.
Download two audio files, .wav and .wav. On the Blackboard, you’ll also find the
he samples.mat file. This is a MATLAB data file which includes samples to be correlated.
didn'tRequirements
Find out which, between the two audio files, can have a pattern similar to the samples.mat. Use
sold the xcorr() function and then plot the generated signal (i.e. the output of this function).
Note: Before processing, normalize both signals so that the amplitude remains within 1.
Observation?
[6]