⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcfit.m

📁 这是一个用于语音信号处理的工具箱
💻 M
字号:

% Script : fit the pitch wave with a cubic or a 2nd order polynomial.
%
%    pcfit.m is a call_function executed by "wave_fit" on figure(Pset_f).

 axx=gcidx1;

 %%% create the modeled pitch wave
 if exist('mwave')==0
     mwave1=[];
     for kk=1:length(knob_xx)-1

              x1x=knob_xx(kk);
              x2x=knob_xx(kk+1);
              y1y=knob_yy(kk);
              y2y=knob_yy(kk+1);
              xxa=(y1y-y2y)/(x1x-x2x);
              xxb=(x1x*y2y-x2x*y1y)/(x1x-x2x);

              qx1=find( axx==x1x );
              qx2=find( axx==x2x );

              nyy=xxa*axx(qx1:qx2)+xxb;
              nyylen=length(nyy);
              mwave1=[mwave1 nyy(1:nyylen-1)]; 
      end
      mwave=[mwave1 nyy(nyylen)];
   end

  % model the segmental pitch wave accoding to the selected polymonial

  figure(Pdis_f);

  [xx,yy]=ginput(1);  % obtain the desired section to model
  x_idx=max( find( knob_xx<xx ) );
  x1x=knob_xx(x_idx);
  x2x=knob_xx(x_idx+1);
  y1y=knob_yy(x_idx);
  y2y=knob_yy(x_idx+1);

  qx1=find( axx==x1x );
  qx2=find( axx==x2x );

  val=get(wave_fit,'Value');

  if val==1
       %-------------------------------------------------------% 
       %      use a straight line to fit the gain envelope     %
       %-------------------------------------------------------%

       xxa=(y1y-y2y)/(x1x-x2x);
       xxb=(x1x*y2y-x2x*y1y)/(x1x-x2x);
       mwave1=xxa*axx(qx1:qx2)+xxb;
  elseif val==2
       %-------------------------------------------------------% 
       %   use a parabola (1) to fit the gain envelope     %
       %-------------------------------------------------------%

        [dum,mwave1]=parafit([x1x x2x],[y1y y2y],1,axx(qx1:qx2) );

 elseif val==3
       %-------------------------------------------------------% 
       %   use a parabola (2) to fit the gain envelope     %
       %-------------------------------------------------------%

        [dum,mwave1]=parafit([x1x x2x],[y1y y2y],2,axx(qx1:qx2) );

  elseif val==4
       %-------------------------------------------------------% 
       %   use a cubic to fit the pitch wave     %
       %-------------------------------------------------------%
        [dum,mwave1]=cubfit([x1x x2x]/25,[y1y y2y],axx(qx1:qx2)/25 );
        % in order to avoid a singular matrix, divide X by 25

  elseif val==5
       %-------------------------------------------------------% 
       %   use the default pitch wave                          %
       %-------------------------------------------------------%

        mwave1=pw1(qx1:qx2);

  end
  mwave(qx1:qx2)=mwave1;

 % seperate the wave by an unvoiced boundary

 NR=length(seglens1);
 sp=1; % starting point of one segment

 for ii=1:NR
      ep=seglens1(ii)+sp-1; % ending point of one segment

      % plot the pitch wave
      plot( gcidx1(sp:ep),pw1(sp:ep),'k' ); hold on;

      % plot the modeled pitch wave
      plot( gcidx1(sp:ep),mwave(sp:ep),'g--' );

      % plot the pitch jitter
      plot(gcidx1(sp:ep),jitter(sp:ep),'r');

      sp=ep+1;
 end


 % plot the  knobs
 plot(knob_xx,knob_yy,'g*');

 hold off;
 title('Pitch Wave (black line) and Pitch Jitter (red line) ');
 
 clear x1x x2x y1y y2y xxa axx xxb mwave1 newxx newyy qx1 qx2 sp ep o_yy;

⌨️ 快捷键说明

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