1
1
function Param = pre_paramInit(c ,window , noverlap , nfft ,pooling ,azBound ,elBound ,gridRes ,alphaRes ,fs ,freqRange ,micPos )
2
2
Param = struct ;
3
- %% Check mandatory params
3
+ %%
4
4
if (isempty(micPos ))
5
- error(' You must specify the microphone positions ' );
5
+ error(' ERROR : 请输入micPos ' );
6
6
else
7
7
[dim1 ,~ ,~ ] = size(micPos );
8
- if (dim1 ~= 3 ),error(' The first dimension of micPos must be 3 - (x,y,z) coordinates ' );end
8
+ if (dim1 ~= 3 ),error(' ERROR : micPos必须是三维坐标 ' );end
9
9
end
10
10
11
11
Param.window = window ;
16
16
if (isempty(freqRange ))
17
17
Param.freqBins = 1 : length(Param .f );
18
18
elseif (freqRange(1 ) < 0 || freqRange(2 ) > Param .fs / 2 )
19
- error(' Frequency range must be between 0Hz and Fs/2 ' );
19
+ error(' ERROR : 频率范围freqRange应在 0Hz 到 fs/2 之间 ' );
20
20
else
21
21
binMin = find(Param .f >= freqRange(1 ),1 ,' first' );
22
22
binMax = find(Param .f < freqRange(2 ),1 ,' last' );
30
30
if (isempty(alphaRes ))
31
31
Param.alphaRes = 5 ;
32
32
elseif (alphaRes < 0 )
33
- error(' Alpha resolution must be a positive value. ' );
33
+ error(' ERROR : alphaRes应为正值 ' );
34
34
else
35
35
Param.alphaRes = alphaRes ;
36
36
end
45
45
elseif (length(azBound ) == 2 && azBound(1 ) >= - 180 && azBound(2 ) <= 180 && azBound(1 )<=azBound(2 ))
46
46
% nothing to do
47
47
else
48
- error(' Azimut boundaries are bad filled. Azimut boundaries could be: \n - One scalar value to locate at a specific azimuth \n - A vector of two ascending values between - /+ 180 ' );
48
+ error(' ERROR : azBound输入不合法,应为在- /+ 180范围内的一个标量或一个二维向量 ' );
49
49
end
50
50
51
51
if (isempty(elBound ))
55
55
elseif (length(elBound ) == 2 && elBound(1 ) >= - 90 && elBound(2 ) <= 90 && elBound(1 )<=elBound(2 ))
56
56
% nothing to do
57
57
else
58
- error(' Elevation boundaries are bad filled. Elevation boundaries could be: \n - One scalar value to locate at a specific elevation \n - A vector of two ascending values between - /+ 90 ' );
58
+ error(' ERROR : elBound输入不合法,应为在- /+ 90范围内的一个标量或一个二维向量 ' );
59
59
end
60
60
61
61
if (length(unique(elBound )) == 1 && length(unique(azBound )) == 1 )
62
- error(' You can not fixed the boundaries for azBound and elBound to an unique value ' );
62
+ error(' ERROR : azBound和elBound至多有一个为标量 ' );
63
63
end
64
64
65
65
Param.azimuth = (azBound(1 ) : gridRes : azBound(2 ))' ;
69
69
Param.azimuthGrid = repmat(Param .azimuth ,nEl ,1 )' ;
70
70
Param.elevationGrid = (reshape(repmat(Param .elevation ,nAz ,1 ),1 ,nAz * nEl ));
71
71
72
- %% 将所有候选方位转换为笛卡尔坐标
72
+ %% 将所有候选方位转换为笛卡尔坐标
73
73
Param.nGrid = length(Param .azimuthGrid ); % (nAlxnEl) x 1
74
74
directionCoordinate = zeros(3 ,Param .nGrid ); % 3 x (nAlxnEl)
75
75
[directionCoordinate(1 ,: ), directionCoordinate(2 ,: ), directionCoordinate(3 ,: )] = sph2cart(Param .azimuthGrid * pi / 180 , Param .elevationGrid * pi / 180 , 1 );
76
- % 所有的麦克风对都初始化一个所有方位的笛卡尔坐标矩阵 3 x nMicPair x nDirction
76
+ % 所有的麦克风对都初始化一个所有方位的笛卡尔坐标矩阵 3 x nMicPair x nDirction
77
77
micPost = (Param .micPos )' ;
78
78
nMic = size(micPost ,1 );
79
79
Param.pairId = nchoosek(1 : nMic ,2 );
80
80
Param.nPairs = size(Param .pairId ,1 );
81
81
coordinate_pair = repmat(directionCoordinate ,[1 1 Param .nPairs ]);
82
82
coordinate_pair = permute(coordinate_pair ,[1 3 2 ]);
83
- %% 所有麦克风对之间的间距
83
+ %% 所有麦克风对之间的间距
84
84
delta12 = micPost(Param .pairId(: ,1 ),: ) - micPost(Param .pairId(: ,2 ),: );
85
85
Param.d = sqrt(sum(delta12 .^ 2 ,2 ));
86
86
delta12_pair = repmat(delta12 ' ,[1 1 Param .nGrid ]);
90
90
Param.tauGrid = cell(1 ,Param .nPairs );
91
91
for index = 1 : Param .nPairs
92
92
Param.alphaSampled{index } = floor(min(Param .alpha(index ,: ))/Param .alphaRes ) * Param .alphaRes : Param .alphaRes : ceil(max(Param .alpha(index ,: ))/Param .alphaRes ) * Param .alphaRes ;
93
- Param.tauGrid{index } = Param .d(index )*cos(Param.alphaSampled{index }.*pi / 180 )./Param .c ; % 时延
93
+ Param.tauGrid{index } = Param .d(index )*cos(Param.alphaSampled{index }.*pi / 180 )./Param .c ; % 时延
94
+ end
94
95
end
95
- end
0 commit comments