📄 psearch.m
字号:
function psearch(sube1)
global frames pdmin pdmax pcbsize pcode pgain TRUE FALSE
global shiftrange szsubf sub_cnt bpb intp pdlyindx pdelay frange prev del_intv
% For the first sub-frame, which is empty, just assume a pitch code
if sub_cnt==1
pcode(sub_cnt)=1;
prev=pcode(sub_cnt);
pgain(sub_cnt)=0.0;
else
% Integer pitch delay search
% Move the intp+pdmin-1 behind of the pitch buffers ahead
pdelay(1:intp+pdmin-1)=bpb(szsubf+1:intp+szsubf+pdmin-1);
if rem(sub_cnt-1,del_intv)~=0 % Full pitch search only on first sub-frame for each frame.
if (prev-shiftrange/2)<=1 %
bkl=1; %
bkh=bkl+shiftrange-1; % Find search range for delta search use
elseif (prev+shiftrange/2)>=pcbsize %
bkh=pcbsize; %
bkl=bkh-shiftrange+1; %
else %
bkl=prev-shiftrange/2; %
bkh=prev+shiftrange/2-1; %
end
% Routine searching integer pitch delay and gain
[pcodei,pgaini,pk1]=pdetect(pdelay,sube1,bkl,bkh,FALSE);
else
bkl=1; bkh=pcbsize; % Full pitch search
% Routine searching integer pitch delay and gain
[pcodei,pgaini,pk1]=pdetect(pdelay,sube1,bkl,bkh,FALSE);
prev=0;
end
% Fractional pitch delay search
bkl=max((pcodei-frange/2),bkl); % Define fractional pitch delay search (small range:6)
bkh=min((pcodei+frange/2-1),bkh);
% Routine searching fractional pitch delay and gain. Fractional and integer search use the same routine,
% which differentiate itself with boolean flag TRUE/FALSE
[pcodef,pgainf,pk2]=pdetect(pdelay,sube1,bkl,bkh,TRUE); %
if pk2<=pk1 % Compare results from the integer and fractional searches
pcode(sub_cnt)=pcodei-prev; % Select the better estimate of pitch delay and gain
pgain(sub_cnt)=pgaini;
prev=pcodei;
else
pcode(sub_cnt)=pcodef-prev;
pgain(sub_cnt)=pgainf;
prev=pcodef;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -