%18-396 Lab 7: Convolution
% This file contains MATLAB code for various parts of Lab 7
%

FS=8000;
DT=1/FS;
Tfinal=10.0;
t=0:DT:Tfinal;

Finitial=0;
Ffinal=2000;

y=chirp(t,Finitial,Tfinal,Ffinal);
sound(y,FS);

specgram(y,128,FS)


t1=0:DT:0.1;
f400=sin(2*pi*400*t1).*exp(-40*t1);  %A 400 Hz sine wave.

z=conv(y,f400);

%Because z is longer than y, create a new vector
%"n" so we can plot just the beginning part of z.
n=1:length(t);  
plot(t,z(n));
xlabel('Time');
ylabel('Convolution');
title('Filtered output');

pause(10);
[ttone,FS,bits]=wavread('touchtone');
soundsc(ttone,FS)