% trois filtrages (parfaits :-) de 2 sons
%----------------------------------------

clear all; close all;

Fe = 22050; h = 1/Fe;
f0 = 220; T =  2;
th = 0:h:T;

% enveloppe
tr = T*[0 .01 .99 1];
yr = [0 1 1 0];
env = envelop(tr,yr,Fe);

% filtrages du son "triangulaire"
%--------------------------------
x1 = sin(2*pi*f0*th).*env;
x2 = sin(4*pi*f0*th)/2.*env;
x3 = (sin(6*pi*f0*th)/3+sin(8*pi*f0*th)/4).*env;
x = [x1,x2,x3];
x = .98*x/(max(abs(x)));
sound(x,Fe);
%wavwrite(x,Fe,'../SONS/119filtretri.wav');
figure(1)
debut = round(Fe+1);
fin = round(Fe+3*Fe/f0);
subplot(3,1,1); plot(x1(debut:fin));
subplot(3,1,2); plot(x2(debut:fin));
subplot(3,1,3); plot(x3(debut:fin));
pause(3*T+2)


% filtrages du son "rectangulaire"
%---------------------------------
x1 = sin(2*pi*f0*th).*env;
x2 = 0*th;
x3 = (sin(6*pi*f0*th)/3+sin(10*pi*f0*th)/5+...
      sin(14*pi*f0*th)/7).*env;
x = [x1,x2,x3];
x = .98*x/(max(abs(x)));
sound(x,Fe);
%wavwrite(x,Fe,'../SONS/120filtrerect.wav');
figure(2)
subplot(3,1,1); plot(x1(debut:fin));
subplot(3,1,2); plot(x2(debut:fin));
subplot(3,1,3); plot(x3(debut:fin));
