rmdup4a.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 115 行
M
115 行
function [f]=rmdup4a(p,f_init)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% jmw
%
% 12/01/93
%
% function to remove duplicate peaks in initial estimates
% for formant slots.
%
% STEP 3 of the McCandless Algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
echo off
if (nargin ==1)
EST1 = 320; % values from McCandless paper for initial estimates
EST2 = 1440;
EST3 = 2760;
EST4 = 3200;
else
EST1 = f_init(1);
EST2 = f_init(2);
EST3 = f_init(3);
EST4 = f_init(4);
end;
EST = [EST1 EST2 EST3 EST4 ];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f = p; % allocate mem
flg = 1; % do while loop at least once ...
while (flg ~= 0),
d = abs(f - EST);
if ( (f(1)-f(2) == 0) & f(1)~=0 & f(2)~= 0 )
% f1 and f2 the same and both non zero
if (d(1) < d(2) )
f(2) = 0;
else
f(1) = 0;
end;
elseif ( (f(1)-f(3) == 0) & f(1)~=0 & f(3)~= 0 )
% f1 and f3 the same and both non zero
if (d(1) < d(3) )
f(3) = 0;
else
f(1) = 0;
end;
elseif ( (f(1)-f(4) == 0) & f(1)~=0 & f(4)~= 0 )
% f1 and f4 the same and both non zero
if (d(1) < d(4) )
f(4) = 0;
else
f(1) = 0;
end;
elseif ( (f(2)-f(3) == 0) & f(2)~=0 & f(3)~= 0 )
% f2 and f3 the same and both non zero
if (d(2) < d(3) )
f(3) = 0;
else
f(2) = 0;
end;
elseif ( (f(2)-f(4) == 0) & f(2)~=0 & f(4)~= 0 )
% f2 and f4 the same and both non zero
if (d(2) < d(4) )
f(4) = 0;
else
f(2) = 0;
end;
elseif ( (f(3)-f(4) == 0) & f(3)~=0 & f(4)~= 0 )
% f3 and f4 the same and both non zero
if (d(3) < d(4) )
f(4) = 0;
else
f(3) = 0;
end;
else
flg = 0;
end;
end;
return;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?