forked from KyleZhang1118/Voice-Separation-and-Enhancement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OnMVDR.m
82 lines (82 loc) · 2.19 KB
/
OnMVDR.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
79
80
81
82
function [Y,SetupStruc] = OnMVDR(S,Transfer,SetupStruc)
K = SetupStruc.K;
hop = SetupStruc.hop;
win = SetupStruc.win;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = size(S,2);
frame_N = size(S,3);
blockWin = repmat(win,[1 N frame_N]);
X = fft(S.*blockWin);
K_m = K/2+1;
Num = size(Transfer,3);
Y = zeros((frame_N-1)*hop+K,Num);
Y_f = zeros(K,frame_N,Num);
%%%%%%%%%%%%%%%%%%%%%%%%%% Initial the coefficients stored in 'SetupStruc'
if(~isfield(SetupStruc,'W'))
SetupStruc.W = permute(Transfer,[2 3 1])/N;
SetupStruc.V = zeros(N,Num,K_m);
sign_Int = 1;
SetupStruc.R = zeros(N,N,K_m);
SetupStruc.WNG = [];
% SetupStruc.miu = [];
% SetupStruc.mag = [];
else
sign_Int = 0;
end
WNG_set = -5;
WNG = zeros(1,K_m);
% miu_ = zeros(1,K_m);
% mag = zeros(1,K_m);
delta2 = 10^(WNG_set/10);
for i = 2:K_m
X_f = permute(X(i,:,:),[2 3 1]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% MVDR processing
W_f = zeros(N,Num);
Steer = permute(Transfer(i,:,:),[2 3 1]);
if(sign_Int==1 || SetupStruc.alpha==1)
R = X_f*X_f'/frame_N;
else
R = (1-SetupStruc.alpha)*SetupStruc.R(:,:,i)+SetupStruc.alpha*(X_f*X_f')/frame_N;
SetupStruc.R(:,:,i) = R;
end
miu = 2/3/sum(real(diag(R)));
for j = 1:Num
h = Steer(:,j);
mo2 = h'*h;
Wc = h/mo2;
Pc0 = eye(N)-Wc*h';
V = SetupStruc.V(:,j,i);
W = SetupStruc.W(:,j,i);
V = Pc0*(V-miu*R*W);
b2 = 1/delta2-1/mo2;
if(V'*V<=b2)
W = Wc+V;
else
W = Wc+sqrt(b2)*V/sqrt(V'*V);
end
W_f(:,j) = W;
SetupStruc.V(:,j,i) = V;
end
SetupStruc.W(:,:,i) = W_f;
WNG(i) = -10*log10(W_f(:,1)'*W_f(:,1));
% mag(i) = abs(W_f(:,1)'*Steer(:,1));
% miu_(i) = miu;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Y_ = W_f'*X_f;
Y_f(i,:,:) = Y_.';
if(i~=K_m)
Y_f(K+2-i,:,:) = Y_';
end
end
SetupStruc.WNG = [SetupStruc.WNG;WNG];
% SetupStruc.miu = [SetupStruc.miu;miu_];
% SetupStruc.mag = [SetupStruc.mag;mag];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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
return;