function [LEF0_x,LEF0_y]=difusion_LEF_funcion(sala)

%clc;clear all

maxtt=155190;%numero de muestras de la respuesta impulsiva
%dt=1.4663e-05;%paso temporal utilizado en la simulación de FDTD
dt=1/44100;
sala=sala(45000:end,:);
fs=44100;
%%
% for ii=1:18
%     salida0bis(:,ii)=resample(sala(:,ii),fs,round(1/dt));
% end
    
salida0bis=sala;%Comentar esto y descomentar lo otro en caso de tener que resamplear
%%
tinicial=0.005;
tfinal=0.080;


for ii=1:6;
    t0(ii)=find(salida0bis(:,ii)/max(abs(salida0bis(:,ii)))>1/100,1,'first');
    t0(ii+6)=t0(ii);t0(ii+12)=t0(ii);
end

for ii=1:18
    
    x(:,:,ii)=filtra(salida0bis(:,ii),44100,1);
    
    xcorta(:,:,ii)=x(t0(ii)+round(tinicial*fs):t0(ii)+round(tfinal*fs),:,ii);
end


for ii=1:18 %banda
    for jj=1:6 %micro
        LEF0_x(ii,jj)=sum(xcorta(:,ii,jj+6).^2)/sum(xcorta(:,ii,jj).^2);
        LEF0_y(ii,jj)=sum(xcorta(:,ii,jj+12).^2)/sum(xcorta(:,ii,jj).^2);
    end
end
        
        
LEF0_x;
LEF0_y;
       
% semilogx(100*2.^(0:5),mean(LEF0_x),100*2.^(0:5),mean(LEF0_y),100*2.^(0:5),mean(LEF0_x)+mean(LEF0_y))
return

%%
% for ii=1:6
%     t0=find(salida0(:,ii)/max(abs(salida0(:,ii)))>1/100,1,'first');
%     
%     
%     omni0(:,ii)=salida0(t0+round(0.005/dt):t0+round(0.080/dt),ii);%desde la muestra t=0+5ms hasta t=0+80ms
% end
% for ii=1:6
%     t0=find(salida0(:,ii+6)/max(abs(salida0(:,ii)))>1/100,1,'first');
%     dirx0(:,ii)=salida0(t0+round(0.005/dt):t0+round(0.080/dt),ii);
% end
% for ii=1:6
%     t0=find(salida0(:,ii+12)/max(abs(salida0(:,ii)))>1/100,1,'first');
%     diry0(:,ii)=salida0(t0+round(0.005/dt):t0+round(0.080/dt),ii);
% end
