📄 pitch_syn.m
字号:
function [e0,buf]=pitch_syn(e0,buf,index,pgain)
global szsubf pdlyindx sub_cnt del_intv pcode TRUE FALSE
% Decode pitch code obtained from delta search into real index pointing to pitch delay table
if rem(sub_cnt-1,del_intv)~=0
anch=del_intv*fix((sub_cnt-1)/del_intv)+1;
index=pcode(anch);
for i=1:rem(sub_cnt-1,del_intv)
index=index+pcode(anch+i);
end
end
leng=length(buf);
lb=leng-szsubf;
m=fix(pdlyindx(index));
buf(1:lb)=buf((1+szsubf):(lb+szsubf));
% For lags shorter than frame size(60), expand the adaptive codeword
% the full codeword length by overlapping and adding the convolution
if pdlyindx(index)-m<10e-4 % if integer pitch synthesis
if(leng-m)>=lb+1
if m<30 % Add in 3rd convolution
buf((lb+1):(lb+m))=buf((lb-m+1):lb);
buf((lb+m+1):(lb+m+m))=buf((lb+1):(lb+m));
buf((lb+m+m+1):leng)=buf((lb+m+1):leng-m);
else % Add in 2dn convolution
buf((lb+1):(lb+m))=buf((lb-m+1):lb);
buf((lb+m+1):leng)=buf((lb+1):leng-m);
end
else
buf((lb+1):leng)=buf((lb+1-m):leng-m);
end
else % else it's fractional pitch synthesis
% Generate fractional pitch delay by interpolation
[buf,buf1]=interpolate(buf,lb+1,szsubf,pdlyindx(index)-m,m);
buf((lb+1):(leng))=buf1(1:szsubf);
end
% Synthesize pitch
e0(1:szsubf)=e0(1:szsubf)+(pgain*buf(lb+1:lb+szsubf));
buf(lb+1:lb+szsubf)=e0(1:szsubf);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -