% tubes, 2 types de commandes
%----------------------------

clear all

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

% commande en pression
%---------------------
f = f0*(1:15);
am = f.^(-2);
n = length(f);

% somme des harmoniques
y = zeros(1,length(th));
for k = 1:n
    z = sin(2*pi*f(k)*th);
    y = y + am(k)*z;    
end

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

y = .98*y/(max(abs(y)));
sound(y,Fe)
%wavwrite(y,Fe,'../SONS/211tubepression.wav');
pause(T+2)

% commande en vitesse
%--------------------
f = f0*(1:2:15);
am = f.^(-2);
n = length(f);

% somme des harmoniques
y = zeros(1,length(th));
for k = 1:n
    z = sin(2*pi*f(k)*th);
    y = y + am(k)*z;    
end

% enveloppe
y = y.*env;

y = .98*y/(max(abs(y)));
sound(y,Fe)
%wavwrite(y,Fe,'../SONS/212tubevitesse.wav');
