function [SIR SDR inputSIR]=siseceval(H,resp) % % Input: H .... separating MIMO filter, either 3D or 4D array % - In case that the algorithm outputs mono-channel separated sources, % the input should be 3D array H such that % filter(H(1,:,i),1,x(1,:))+filter(H(2,:,i),1,x(2,:)) % yields the i-th separated source. Here, x(i,:) is the % signal from the i-th microphone. % - In case that the algorithm outputs separated microphone responses % (images) of sources, the input should be 4D array H such that % filter (H(1,:,i,j),1,x(1,:))+filter(H(2,:,i,j),1,x(2,:)) % yields the separated response (image) of the i-th source at the j-th microphone. % resp .... 3D array of microphone responses of individual sources % such that resp(i,:,j) is the response (image) of the j-th source % at the i-th microphone. Available only for organizers. % % Outputs: SIR .... vector 1x2 .. output SIR of separated signals, such that % SIR(1,i) is the SIR of the i-th signal. % In case that H is 4D, the SIR is averaged over the microphones. % % SDR .... vector 1x2 .. output SDR of separated signals, such that % SDR(1,i) is the SDR of the i-th signal. % In case that H is 4D, the SDR is averaged over the % microphones. % inputSIR .... inputSIR(i,j) is the SIR of the j-th source at the i-th microphone in x % % x=sum(resp,3); % these sums are available to the participants % file names e.g. room1set1x1.wav % can be loaded by loadsisec.m inputSIR(:,1)=mean(resp(:,:,1).^2,2)./mean(resp(:,:,2).^2,2); % input SIR the first source inputSIR(:,2)=mean(resp(:,:,2).^2,2)./mean(resp(:,:,1).^2,2); % input SIR the second source if ndims(H)==4 % algorithm estimates responses for i=1:2 % estimated source index for j=1:2 % microphone index est_resp(j,:,i)=filter(H(1,:,i,j),1,x(1,:))+filter(H(2,:,i,j),1,x(2,:)); % estimated responses (images) for trgt=1:2 % target source index jmmr=setdiff([1 2],trgt); % jammer source index % equivalently jmmr=3-trgt; sir(j,trgt,i)=mean((filter(H(1,:,i,j),1,resp(1,:,trgt))+filter(H(2,:,i,j),1,resp(2,:,trgt))).^2)/... mean((filter(H(1,:,i,j),1,resp(1,:,jmmr))+filter(H(2,:,i,j),1,resp(2,:,jmmr))).^2); % % SIR of the i-th estimated source at the j-th microphone assuming the target signal is the trgt-th % original source sdr(j,trgt,i)=calcSDR(resp(j,:,trgt),est_resp(j,:,i),size(H,2)); % % SDR of the i-th estimated source at the j-th microphone assuming the target signal is the trgt-th % original source, maximum system delay is +-size(H,2) end end end SIR2=squeeze(mean(sir,1))'; % average sir over microphones SDR2=squeeze(mean(sdr,1))'; % average sdr over microphones else % algorithm estimates mono-sources SIR2=zeros(2,2); SDR2=zeros(2,2); for i=1:2 % estimated source est_source(i,:)=filter(H(1,:,i),1,x(1,:))+filter(H(2,:,i),1,x(2,:)); for trgt=1:2 % target source jmmr=setdiff([1 2],trgt); SIR2(i,trgt)=mean((filter(H(1,:,i),1,resp(1,:,trgt))+filter(H(2,:,i),1,resp(2,:,trgt))).^2)/... mean((filter(H(1,:,i),1,resp(1,:,jmmr))+filter(H(2,:,i),1,resp(2,:,jmmr))).^2); SDR2(i,trgt)=max([calcSDR(resp(1,:,trgt),est_source(i,:),size(H,2))... calcSDR(resp(2,:,trgt),est_source(i,:),size(H,2))]); % SDR is computed with respect to both of the microphone responses, the better SDR % is selected to be the overall SDR % Note that this criterion is sensitive to filtering of separated sources end end end % if H is 4D or 3D % Assigning estimated sources to original ones based on maximum SIR. % The stronger source is assigned first. [SIR22,ind]=max(SIR2); % if SIR22(1)>SIR22(2) SIR(1,1)=SIR2(ind(1),1); SIR(1,2)=SIR2(3-ind(1),2); SDR(1,1)=SDR2(ind(1),1); SDR(1,2)=SDR2(3-ind(1),2); else SIR(1,1)=SIR2(3-ind(2),1); SIR(1,2)=SIR2(ind(2),2); SDR(1,1)=SDR2(3-ind(2),1); SDR(1,2)=SDR2(ind(2),2); end disp('input SIR [dB]:') disp(10*log10(inputSIR)) disp('SIR [dB]:') disp(10*log10(SIR)) disp('SDR [dB]:') disp(10*log10(SDR)) % ------------------------------------------------------ function SDRout=calcSDR(resp,micros,L) % % computes signal-to-distortion ratio of the true signal "resp" in its estimate "micros" % L ... maximum absolute delay of "micros" w.r.t. "resp" % (the delay can be both positive or negative) % % both signals, "resp" and "micros" are centered and normalized to have unit variance % resp=resp-mean(resp); resp=resp/sqrt(mean(resp.^2)); micros=micros-mean(micros); micros=micros/sqrt(mean(micros.^2)); % resp=[zeros(1,L) resp zeros(1,L)]; % initial time delay of "resp" is L SDR=zeros(1,2*L+1); for i=0:2*L micros2=[zeros(1,i) micros zeros(1,2*L-i)]; % micros delayed by i samples SDR(i+1)=1/mean((micros2-resp).^2); % SDR at the mutual delay i-L end [SDRout L]=max(SDR);