% Chowning, variation de beta
%----------------------------

clear all; close all;

Fe = 22050;
f0 = 220; T = 1.5;
h = 1/Fe; t = 0:h:T;

beta  = f0*[0 1 2 3 4];
lf = length(beta);

tt = Fe/2+(1:ceil(10*Fe/f0));

tr = T*[0 .002 .3 .9 1];
yr = [0 1 .4 .1 0];
env = envelop(tr,yr,Fe);

f1 = f0;
figure(1);
y = [];
silence = zeros(1,round(Fe/2));
for k = 1:lf
    s = sin(2*pi*f0*t+beta(k)*sin(2*pi*f1*t)/f1);
    s = .95*s.*env;
    num = num2str(k);
    subplot(lf,1,k);
    plot(t(tt),s(tt));
    sound(s,Fe); pause(T+1);
    y = [y silence s];
end
%wavwrite(y,Fe,'../SONS/602chowningb.wav');

f1 = 2*f0;
figure(2);
y = [];
for k = 1:lf
    s = sin(2*pi*f0*t+beta(k)*sin(2*pi*f1*t)/f1);
    s = .95*s.*env;
    num = num2str(k);
    subplot(lf,1,k);
    plot(t(tt),s(tt));
    sound(s,Fe); pause(T+1);
    y = [y silence s];
end
%wavwrite(y,Fe,'../SONS/603chowningc.wav');
