g_gci.m

来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 74 行

M
74 行
字号
% FUNCTION: G_GCI generates the GCI sequence from three components of the pitch
%           contour.
% USUAGE: ngci=g_gci(p0,pw,jitter,gcidx,seglens);
%
% OUTPUT : gci == GCI sequence of a voiced sound
% INPUT : p0 == fundamental pitch period
%          pw == the pitch wave
%          jitter == perturbation of the pitch contour
%          gcidx == gci index for the segmental pc contour
% See also: pctour.

function ngci=g_gci(p0,pw,jitter,gcidx,seglens);

 %-----------------------------%
 % constrcut the pitch contour %
 %-----------------------------%
  % Why?
  % the length of the pitch period has been changed, the glottal closure 
  % indices therefore must be adjusted to fit the new pitch contour. 

 NR=length(seglens);
 sp=1;
 ngci=[];
 for kf=1:NR
     ep=seglens(kf)+sp-1;

     % make the new pitch contour
 
     numgci=seglens(kf); % number of GCIs in this segment
    
     % tmppc==temporary pitch contour of this segment
     tmppc=pw(sp:ep);
     %jitter=pb*p0*randn(1,numgci);
     tmppc=tmppc+p0*ones(1,numgci)+jitter(sp:ep);

     % pitch contour
     xref=gcidx(sp:ep);
     yref=tmppc;

     % contruct the new pw & gcidx

     firstp=gcidx(sp); % first GCI in this segment
     lastp=gcidx(ep); % last GCI in this segment

     ix=1; % index of GCIs in this segment
     tmpgci(ix)=firstp; % new GCIs
     npc(ix)=tmppc(ix);

     % the following loop tries to find the new gci to fit the pitch contour
     ix=2;
     nxpt=round( tmpgci(ix-1)+npc(ix-1) );
     while nxpt < lastp

          tmpgci(ix)=nxpt;
          npc(ix)=interp1(xref,yref,nxpt);
          ix=ix+1;
          nxpt=round( tmpgci(ix-1)+npc(ix-1) );
     end

     % add one more GCI if less than 40% 
     if (nxpt-lastp)<0.41*p0
        tmpgci(ix)=nxpt;
        npc(ix)=mean( npc(ix-3:ix-1) ); 
     else
        ix=ix-1;
     end

     ngci=[ngci tmpgci];

     clear npc tmpgci tmppc;

     sp=ep+1;
  end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?