-
Notifications
You must be signed in to change notification settings - Fork 7
/
maskDrivenMvdr.m
52 lines (43 loc) · 1.65 KB
/
maskDrivenMvdr.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
function Y = maskDrivenMvdr(X, M, tdoa, Ncov)
% Perform MVDR beamforming using a mask and a look direction
%
% Inputs
% X FxTxC array of complex spectrograms for each (non failed) mic
% M FxT matrix of a mask for all channels where 1 is target, 0 not
% tdoa Cx1 vector of time delays at each microphone measured in samples
%
% Outputs
% Y FxT matrix of a complex spectrogram of the MVDR output
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2015 Michael Mandel
% University of Sheffield (Jon Barker, Ricard Marxer)
% Inria (Emmanuel Vincent)
% Mitsubishi Electric Research Labs (Shinji Watanabe)
% This software is distributed under the terms of the GNU Public License
% version 3 (http://www.gnu.org/licenses/gpl.txt)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('Ncov', 'var'), Ncov = []; end
regul=1e-3; % MVDR regularization factor
[F T C] = size(X);
wlen = 2*(F-1);
X = permute(X, [3 2 1]); % Now it is CxTxF
if isempty(Ncov)
% Estimate noise covariance
Ncov = zeros(C, C, F);
for f = 1:F
%Ncov(:,:,f) = X(:,:,f) * bsxfun(@times, X(:,:,f), 1-M(f,:))';
Tcov = covw(X(:,:,f)', 1-M(f,:)');
Ncov(:,:,f) = 0.5 * (Tcov + Tcov'); % Ensure Hermitian symmetry
end
end
% MVDR beamforming
Xa = squeeze(mean(abs(X).^2,2));
Y = zeros(F,T);
for f = 1:F,
Df = sqrt(1/C) * exp(2*1i*pi*(f-1)/wlen*tdoa); % steering vector
Dfs(:,f) = Df;
Rt = Ncov(:,:,f) + regul * diag(Xa(:,f)); % regularized noise covariance
DR = Df'/Rt;
Y(f,:) = (DR * X(:,:,f)) / real(DR * Df);
end
% plot(angle(Dfs)')