gcapp.m

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

M
107
字号
%FUNCTION: Apply the pitch contour modification.
%  
%  gcapp.m is a call function by "apply_pb" on figure(Gcset_f).

if App==1 % execute the apply buttom
          %-------------------------

 
   % 1. construct new gain contour -- ngm3
   %--------------------------------------

   val=get(env_dsp,'Value');

   if val==1  % label grossly
      if exist('menv')==1
         genv1=menv;
      end
   else  % label detailedly
      genv1=knob_yy;
   end

   gntour1=genv1+gcpert;

   % check if the seting is O.K. ( the gain value should not be negative )
   checkk=find(gntour1<0);
   if ~isempty(checkk)
       gntour1(checkk)=-0.5*gntour1(checkk);
   end
   clear checkk;

   % ---interpolate ngm3 from gntour1---
   m_len=basic(5)-basic(6);
   ngm3=zeros(nframe,4);

   % the gain of the first and last frame is fixed as the original
   % in order to have a better sound when played though a D/A converter.
   kf=1;
      ngm3(kf,:)=ngm1(kf,:);
     
   for kf=2:nframe-1
      gm_x=[-1*m_len/2 m_len/2 m_len+m_len];
      gm_y=[gntour1(kf-1) gntour1(kf) gntour1(kf+1)];
      gm_z=m_len/4*[0 1 2 3]+m_len/8;
      tmp=interp1(gm_x,gm_y,gm_z);
      ngm3(kf,1:4)=tmp(:)';
   end
   kf=nframe;
      ngm3(kf,:)=ngm1(kf,:);

   clear tmp gm_x gm_y gm_x;


   % 2. construct new gm3
   %------------------------------

   gm_x=1;
   gm_y=0;

   for kf=1:nframe
       startp=m_len*(kf-1)+Order+1;
       tmp_x=m_len/4*[0 1 2 3]+m_len/8+startp;
       gm_x=[gm_x tmp_x];
       gm_y=[gm_y ngm3(kf,1:4)];
   end
   gm_x=[gm_x startp+m_len-1];
   gm_y=[gm_y 0];

   if exist('gci3')==0
      gci1=gci;
   else
      gci1=gci3;
   end

   % interpolate the new gm3
   gm3=interp1( gm_x,gm_y,gci1 );
   gm3=gm3(:)';
   %ave=mean(gm3);
   %gm3=filter(0.4,[1 -0.4 -0.2],gm3);
   %gm3=gm3+(ave-mean(gm3));
   %gm3=abs(gm3);

   % plot the new genv1
   clear gm_x gm_y gci1
   gcplt;

elseif App==0 % execute the undo buttom
              %------------------------

   if exist('ngm3')==1
      ngm1=ngm3;
   else
      ngm1=ngm;
   end

   [genv1,gb1,gntour1]=gaintr(ngm1); 

   set(pertb_cg,'Value',gb1);
   set(pertb_cg,'Max',2*gb1);
   set(pertb_val,'String',num2str(gb1));
   gcplt;

end 

clear menv;
set(env_up,'Visible','off');
set(env_down,'Visible','off');

⌨️ 快捷键说明

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