Skip to content

Commit 3d20d59

Browse files
Update pre_paramInit.m
1 parent 3b57961 commit 3d20d59

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ssl_tools/pre_paramInit.m

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
function Param = pre_paramInit(c,window, noverlap, nfft,pooling,azBound,elBound,gridRes,alphaRes,fs,freqRange,micPos)
22
Param = struct;
3-
%% Check mandatory params
3+
%%
44
if(isempty(micPos))
5-
error('You must specify the microphone positions');
5+
error('ERROR : 请输入micPos');
66
else
77
[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
99
end
1010

1111
Param.window = window;
@@ -16,7 +16,7 @@
1616
if(isempty(freqRange))
1717
Param.freqBins = 1:length(Param.f);
1818
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 之间');
2020
else
2121
binMin = find(Param.f >= freqRange(1),1,'first');
2222
binMax = find(Param.f<freqRange(2),1,'last');
@@ -30,7 +30,7 @@
3030
if(isempty(alphaRes))
3131
Param.alphaRes = 5;
3232
elseif(alphaRes < 0)
33-
error('Alpha resolution must be a positive value.');
33+
error('ERROR : alphaRes应为正值');
3434
else
3535
Param.alphaRes = alphaRes;
3636
end
@@ -45,7 +45,7 @@
4545
elseif(length(azBound) == 2 && azBound(1) >= -180 && azBound(2) <= 180 && azBound(1)<=azBound(2))
4646
% nothing to do
4747
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范围内的一个标量或一个二维向量');
4949
end
5050

5151
if(isempty(elBound))
@@ -55,11 +55,11 @@
5555
elseif(length(elBound) == 2 && elBound(1) >= -90 && elBound(2) <= 90 && elBound(1)<=elBound(2))
5656
% nothing to do
5757
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范围内的一个标量或一个二维向量');
5959
end
6060

6161
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至多有一个为标量');
6363
end
6464

6565
Param.azimuth = (azBound(1) : gridRes : azBound(2))';
@@ -69,18 +69,18 @@
6969
Param.azimuthGrid = repmat(Param.azimuth,nEl,1)';
7070
Param.elevationGrid = (reshape(repmat(Param.elevation,nAz,1),1,nAz*nEl));
7171

72-
%% 将所有候选方位转换为笛卡尔坐标
72+
%% 将所有候选方位转换为笛卡尔坐标
7373
Param.nGrid = length(Param.azimuthGrid); % (nAlxnEl) x 1
7474
directionCoordinate = zeros(3,Param.nGrid); % 3 x (nAlxnEl)
7575
[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
7777
micPost = (Param.micPos)';
7878
nMic = size(micPost,1);
7979
Param.pairId = nchoosek(1:nMic,2);
8080
Param.nPairs = size(Param.pairId,1);
8181
coordinate_pair = repmat(directionCoordinate,[1 1 Param.nPairs]);
8282
coordinate_pair = permute(coordinate_pair,[1 3 2]);
83-
%% 所有麦克风对之间的间距
83+
%% 所有麦克风对之间的间距
8484
delta12 = micPost(Param.pairId(:,1),:) - micPost(Param.pairId(:,2),:);
8585
Param.d = sqrt(sum(delta12.^2,2));
8686
delta12_pair = repmat(delta12',[1 1 Param.nGrid]);
@@ -90,6 +90,6 @@
9090
Param.tauGrid = cell(1,Param.nPairs);
9191
for index = 1:Param.nPairs
9292
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
9495
end
95-
end

0 commit comments

Comments
 (0)