%Función Reverberador Modificado de Schroeder(latereverb)
%---------------------------------
%y salida,  x entrada, fs= frecuencia de sampling, s=size, rt= tiempo de
%reverberacion
function yf=latereverb(x,fs,s,rt)

%Ganancias segun RT
G(1) = 10^(-3*0.0398/rt);
G(2) = 10^(-3*0.0431/rt);
G(3) = 10^(-3*0.0317/rt);
G(4) = 10^(-3*0.0357/rt);
G(5) = 0.66; % del 1er filtro pasatodo
G(6) = 0.7 ; % del 2do filtro pasatodo

%Filtros comb en paralelo
dc01=int32(fs*0.0398);ya =combfilter(x,s,dc01,G(1));
dc2=int32(fs*0.0431);yb =combfilter(x,s,dc2,G(2));
dc3=int32(fs*0.0317);yc =combfilter(x,s,dc3,G(3));
dc4=int32(fs*0.0357);yd =combfilter(x,s,dc4,G(4));
yp(:,1)=ya+yb+yc+yd;
%yf(:,2)=ya+yb+yc+yd;

%Filtros Pasatodo en serie
del1r=int32(fs*0.0044); yi(:,1)=allpass(yp,s,del1r,G(5));
del2r=int32(fs*0.0017); yf(:,1)=allpass(yi(:,1),s,del2r,G(6));
del1l=int32(fs*0.0049); yi(:,2)=allpass(yp,s,del1l,G(5));
del2l=int32(fs*0.0016); yf(:,2)=allpass(yi(:,2),s,del2l,G(6));

