function y = wawa(x,Fe,fc,fb,type)
%        y = wawa(x,Fe,fc,fb,type)
% type = pb pour passe-bas, sinon passe-haut
%-------------------------------------------

n = length(x);
y = 0*x;
c = (tan(pi*fb/Fe)-1)./(tan(pi*fb/Fe)+1);
d = -cos(2*pi*fc/Fe);

y(1) = -c(1)*x(1);

k = 2;
ck = c(k); dk = d(k);
y(k) = -ck*x(k)+dk*(1-ck)*(x(k-1)-y(k-1));

for  k = 3:n
    ck = c(k); dk = d(k);
    y(k) = ck*(y(k-2)-x(k))+dk*(1-ck)*(x(k-1)-y(k-1))+x(k-2);
end

if strcmp(type,'pb')
    y = (x-y)/2;
else
    y = (x+y)/2;
end

t = (n-1)/Fe;
tr = t*[0 .05 .92 .96 1];
yr = [0 1 1 .01 0];
env = envelop(tr,yr,Fe);
y = y.*env;
y = .98*y/(max(abs(y)));
