function ie=sep_ibm(x,i) % SEP_IBM STFT-domain source separation via ideal binary masking % % ie=sep_ibm(x,i) % % Inputs: % x: nchan x nsampl matrix containing nchan time-domain mixture signals % with nsampl samples % i: nsrc x nsampl x nchan matrix containing the the true spatial source % images of nsrc sources % % Output: % ie: nsrc x nsampl x nchan matrix containing the estimated spatial source % images % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Copyright 2008 Emmanuel Vincent % This software is distributed under the terms of the GNU Public License % version 3 (http://www.gnu.org/licenses/gpl.txt) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Errors and warnings %%% if nargin<2, error('Not enough input arguments.'); end [nchan,nsampl]=size(x); [nsrc,nsampl2,nchan2]=size(i); if nsampl2~=nsampl, error('The number of samples is different within the mixture and the true source images.'); end if nchan2~=nchan, error('The number of channels is different within the mixture and the true source images.'); end %%% STFT %%% X=stft_multi(x); [nbin,nfram,nchan]=size(X); I=reshape(stft_multi(reshape(permute(i,[1 3 2]),nsrc*nchan,nsampl)),nbin,nfram,nsrc,nchan); %%% Computing ideal binary masks %%% W=zeros(nbin,nfram,nsrc); disto=zeros(nbin,nfram,nsrc); for j=1:nsrc, disto(:,:,j)=sum(abs(permute(I(:,:,j,:),[1 2 4 3])-X).^2,3)+sum(sum(abs(I(:,:,[1:j-1 j+1:nsrc],:)).^2,4),3); end [disto,ind]=min(disto,[],3); W((1:nbin).'*ones(1,nfram)+ones(nbin,1)*nbin*(0:nfram-1)+(ind-1)*nbin*nfram)=1; %%% Applying the masks %%% Ie=repmat(W,[1 1 1 nchan]).*repmat(permute(X,[1 2 4 3]),[1 1 nsrc 1]); %%% ISTFT %%% ie=istft_multi(Ie,nsampl); return;