function y = ajuste(f,Fe,T,am,a,b)
%        y = ajuste(f,Fe,T,am,a,b)
% la frequence diminue (a > 0) ou augmente (a < 0)
% progressivement en se rapprochant de f
%-------------------------------------------------

h = 1/Fe;
th = 0:h:T;

% calcul de la frequence variable f0 et de sa primitive F0
n = length(am); harm = 1:n;
F0 = 2*pi*(f*th + a*log(b+th));
f0 = f + a./(b+th);
plot(f0);
title('frequence instantannee de la note qu''on ajuste');

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

% enveloppe
tr = T*[0 .02 .98 1];
yr = [0 1 1 0];
y = y.*envelop(tr,yr,Fe);
y = .98*y/(max(abs(y)));
