% son ascendant perpetuel (a)
% u_k(t) = sin(2*pi*phi_k(t))
% phi_k(t) = alpha^k/b*exp(b*t)
% f_k(t) = phi_k'(t) = alpha^k*exp(b*t)
%--------------------------------------

clear all; close all;

Fe = 22050; 
B = Fe/2.05; 
h = 1/Fe; T = 1;
t = 0:h:T;
lt = length(t);

%alpha = 2; b = .1; % par octaves
%alpha = 1.5; b = .1; % par quintes
alpha = 1.25; b = .07; % par tierces majeures
y = zeros(1,lt);

for k = 1:1:50
   phi = alpha^k/b*exp(b*t);
   env = (max((B-b*phi)/B,0)).^2;
   y = y+env.*sin(2*pi*phi);
end

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

sound(y,Fe);
%wavwrite(y,Fe,'../SONS/402monteea1.wav');
%wavwrite(y,Fe,'../SONS/403monteea2.wav');
specgram(y);
