-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathGenerateDifferentialBeamformer.m
112 lines (97 loc) · 2.63 KB
/
GenerateDifferentialBeamformer.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
%
% Generate differential beamformers.
%
clear;
addpath('array');
%% generate array
% circular microphone array diameter (m)
d=0.065;
% number of microphones
M=6;
array=circularArray(d, M);
% save microphone coordinates
saveArray(array, 'array.txt');
showArray(array);
%% generate beamformers
% fft block size
fftsize=640;
F=fftsize/2;
% frequency (Hz) of each fft bin
f=0:25:7975;
% white noise gain (dB)
% wngthdb=5;
wngthdb = -10;
% look directions (azimuth) (degree)
% az=-180:120:180-120;
az = 0;
% look direction (elevation) (degree)
% el=45;
el = 0;
W=cell(length(az), F);
wngth=10^(wngthdb/10);
hsv=phased.SteeringVector('SensorArray', array, 'PropagationSpeed', 340);
for fi=1:F
for azi=1:length(az)
%
% Synthetic noise covariance matrix, with three nulls at the left,
% right, and back side of the look direction.
%
a1=step(hsv, f(fi), [doaMod(az(azi)-180); el]);
a2=step(hsv, f(fi), [doaMod(az(azi)-90); el]);
a3=step(hsv, f(fi), [doaMod(az(azi)+90); el]);
C=(a1*a1')+(a2*a2')+(a3*a3');
% make covariance matrix Hermitian
C=(C+C')/2;
% steering vector for the look direction
a=step(hsv, f(fi), [az(azi); el]);
% solve beamformer by CVX
cvx_begin
variable w(M) complex
minimize(w'*C*w)
subject to
% distortionless constraint
w'*a == 1;
% white noise gain constraint
w'*w <= 1/wngth;
cvx_end
W{azi, fi}=w;
end
end
%% plot performance indices
W0=cell(F, 1);
idx0=1;
for fi=1:F
W0{fi}=W{idx0, fi};
end
figure(2);
plotWidebandBeampattern(array, f, W0, el);
figure(3);
ff=[f(41); f(81); f(161); f(241)];
ww={W0{41}; W0{81}; W0{161}; W0{241}};
plotBeampatternCartesian(array, ff, ww, el, 1e-3);
legend('1k', '2k', '4k', '6k');
% directivity index
figure(4);
plotWidebandDirectivityIndex(array, f, W0, [az(idx0); el]);
% white noise gain
figure(5);
plotWidebandWhiteNoiseGain(array, f, W0, [az(idx0); el]);
%
% save beamformers into file
% looks: look directions (degree) [numlooks]
% W: cell contain beamformers {numlooks, numbins} (nummics)
% path: output file path
%
saveBeamformers(az, W, 'differential.f32');
%
% mod degrees in the range of [-180, 180]
% degree: input degree
%
function doa = doaMod(degree)
doa = mod(degree, 360.0);
if doa < -180.0
doa = doa + 360.0;
elseif doa > 180.0
doa = doa - 360.0;
end
end