forked from KyleZhang1118/Voice-Separation-and-Enhancement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Process_LCMV_AESB.m
78 lines (78 loc) · 2.37 KB
/
Process_LCMV_AESB.m
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function [Y,W,SetupStruc] = Process_LCMV_AESB(s,Transfer,SetupStruc)
K = SetupStruc.LCMV_AESB.K;
hop = SetupStruc.LCMV_AESB.hop;
win = hanning(K,'periodic');
win = win/sqrt(sum(win(1:hop:K).^2));
SetupStruc.LCMV_AESB.win = win; % Preserve 'win' in 'SetupStruc'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = size(s,2);
for i = 1:N
X(:,:,i) = fft(enframe(s(:,i),win,hop)');
end
frame_N = size(X,2);
K_m = K/2+1;
Num = size(Transfer,3);
Y = zeros((frame_N-1)*hop+K,Num);
Y_f = zeros(size(X,1),size(X,2),Num);
WNG =zeros(K_m,Num);
%%%%%%%%%%%%%%%%%%%%%%%%%% Obtain processing matrix 'W'
theta = 10^-4;
W = zeros(Num,N,K_m);
% sign_MVDR=0;sign_LCMV=0;sign = zeros(K_m,1);
sign_zero=0;sign_N=0;sign_Num=0;
for i = 2:K_m
X_f = permute(X(i,:,:),[3 2 1]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% LCMV processing, imposing the linear constraints to the angle of sources
W_f = zeros(N,Num);
Steer = permute(Transfer(i,:,:),[2 3 1]);
[E,D] = PCA(X_f);
Num_PCA = size(D,1);
[~,adaD] = PCA(X_f,1,N,D(1,1)*theta);
aNum = size(adaD,1);
if(aNum>Num) aNum = Num;sign_N=sign_N+1;end
if(aNum==Num) sign_Num = sign_Num+1; end
if(Num_PCA<1)
R_inv = eye(N);
sign_zero=sign_zero+1;
else
if(aNum>Num_PCA)
aNum = Num_PCA;
end
E = E(:,1:aNum);
D = D(1:aNum,1:aNum);
if(~isempty(find(diag(D)<theta, 1)))
D = D+min(diag(D))*eye(aNum);
end
R_inv = E/D*E';
end
R_denominator = Steer'*R_inv*Steer;
if(rcond(Steer'*Steer)<theta || rcond(R_denominator)<theta) %%% Judge the covariance matrix of steering vector whether full-rank,
for j = 1:Num %%% otherwise using MVDR
h = Steer(:,j);
W_f(:,j) = R_inv*h/(h'*R_inv*h);
end
% sign_MVDR = sign_MVDR+1;sign(i)=-1;
else
W_f = R_inv*Steer/R_denominator;
% sign_LCMV = sign_LCMV+1;sign(i)=1;
end
W_f = W_f';
W(:,:,i) = W_f;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WNG(i,:) = -10*log10(diag(W_f*W_f')');
Y_ = W_f*X_f;
Y_f(i,:,:) = Y_.';
if(i~=K_m)
Y_f(K+2-i,:,:) = Y_';
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Recover signals
if(K/hop==2)
win = ones(K,1);
end
for i = 1:Num
Y(:,i) = overlapadd(real(ifft(Y_f(:,:,i)))',win,hop);
end
% autoPlot(WNG,'LCMV_AESB');
return;