-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsrc_image.m
More file actions
47 lines (42 loc) · 1.58 KB
/
Copy pathsrc_image.m
File metadata and controls
47 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function I=src_image(S,A)
% SRC_IMAGE STFT-domain projection of sources into the mixture domain,
% given the mixing matrix for instantaneous mixtures or the
% frequency-dependent mixing matrix for convolutive mixtures
%
% I=src_image(S,A)
%
% Inputs:
% S: nbin x nfram x nsrc matrix containing the source STFT coefficients
% A: either a nchan x nsrc mixing matrix (for instantaneous mixtures) or a
% nchan x nsrc x nbin frequency-dependent mixing matrix (for convolutive
% mixtures)
%
% Output:
% I: nbin x nfram x nsrc x nchan matrix containing the STFT coefficients of
% the 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
[nbin,nfram,nsrc]=size(S);
if nbin==2*floor(nbin/2), error('The number of frequency bins must be odd.'); end
[nchan,nsrc2,nbin2]=size(A);
if nsrc2~=nsrc, error('The number of sources is different within the source matrix and the mixing matrix.'); end
if nbin2==1,
A=repmat(A,[1 1 nbin]);
elseif nbin2~=nbin,
error('The number of frequency bins is different within the sources and the frequency-dependent mixing matrix.');
end
%%% Filtering %%%
I=zeros(nbin,nfram,nsrc,nchan);
for j=1:nsrc,
for f=1:nbin,
Ijf=A(:,j,f)*S(f,:,j);
I(f,:,j,:)=reshape(Ijf.',1,nfram,1,nchan);
end
end
return;