% effet de masquage : testez votre oreille
%-----------------------------------------

clear all; close all;

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

f0 = 1000;
f1 = 2500;
DB = -55:5:-35;
am = 10.^(DB/20);

% la petite enveloppe
tr = T*[0 .02 .98 1];
yr = [0 1 1 0];
env = envelop(tr,yr,Fe);

% la suite de sons simultanes, le second (f1) 
% de plus en plus intense
x0 = sin(2*pi*f0*th);
for k = 1:length(am)
    x = (x0 + am(k)*sin(2*pi*f1*th)).*env;
    x = .98*x/(max(abs(x)));
    sound(x,Fe);
    fm = num2str(f1);
    db = num2str(DB(k));
    %eval(['wavwrite(x,Fe,''../SONS/mask' fm '-' db '.wav'');']);
    pause(T+1);
end
