Home > pitchmark > pitchmarkMIN.m

pitchmarkMIN

PURPOSE ^

PITCHMARKMIN Pitch Mark MIN

SYNOPSIS ^

function pitchmarks = pitchmarkMIN(y, fs, maxPeriod, minPeriod, SFS_pitchcurve, plotopt)

DESCRIPTION ^

PITCHMARKMIN Pitch Mark MIN
   Usage : pitchmarks = pitchmarkMIN(y, fs, maxPeriod, minPeriod, SFS_pitchcurve, plotopt)
   Selfdemo : pitchmarkMIN;
   
   The follwoing example shows how to use this function.

   a = (1/pitch);
   b = a*0.5;
   maxPeriod = a + b;
   minPeriod = a - b;
   plotopt = 1;
   pitchmarks = pitchmarkMIN(y, fs, maxPeriod, minPeriod, plotopt);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pitchmarks = pitchmarkMIN(y, fs, maxPeriod, minPeriod, SFS_pitchcurve, plotopt)
0002 
0003 %PITCHMARKMIN Pitch Mark MIN
0004 %   Usage : pitchmarks = pitchmarkMIN(y, fs, maxPeriod, minPeriod, SFS_pitchcurve, plotopt)
0005 %   Selfdemo : pitchmarkMIN;
0006 %
0007 %   The follwoing example shows how to use this function.
0008 %
0009 %   a = (1/pitch);
0010 %   b = a*0.5;
0011 %   maxPeriod = a + b;
0012 %   minPeriod = a - b;
0013 %   plotopt = 1;
0014 %   pitchmarks = pitchmarkMIN(y, fs, maxPeriod, minPeriod, plotopt);
0015 
0016 
0017 if nargin <6, plotopt = 0; end;
0018 if nargin <4, maxPeriod = 0.007; minPeriod = 0.0065; SFS_pitchcurve = 200; plotopt = 1; end;
0019 if nargin==0, selfdemo; return; end;
0020 
0021 pitch = 1/((maxPeriod+minPeriod)/2); %︳衡ㄓpitch
0022 
0023 % =====т程y
0024 [junk, pitchmarks] = min(y);
0025 %┕тN pitch marks
0026 while (1),
0027    currentIndex = pitchmarks(end);
0028    minIndex = currentIndex+floor(minPeriod*fs);
0029    maxIndex = currentIndex+ceil(maxPeriod*fs);
0030    if maxIndex >= length(y) ,
0031       if (length(y)- pitchmarks(end)) > (fs/pitch), %安程pitch markび
0032          begin = pitchmarks(end)+ round((fs/pitch)/2);
0033          candidateY = y(begin : end);
0034          [junk, newIndex] = min(candidateY);
0035          pitchmarks = [pitchmarks, begin+newIndex-1];
0036       end;
0037       break; 
0038    end;
0039    candidateY = y(minIndex:maxIndex);
0040    [junk, newIndex] = min(candidateY);
0041    pitchmarks = [pitchmarks, minIndex+newIndex-1];
0042 end
0043 %┕玡тM pitch marks
0044 while (1)
0045    currentIndex = pitchmarks(1);
0046    maxIndex = currentIndex-floor(minPeriod*fs);
0047    minIndex = currentIndex-ceil(maxPeriod*fs);
0048    if minIndex <= 0 , %临Τ程pitch mark
0049       if pitchmarks(1) > (fs/pitch), %安ヘ玡材pitch mark
0050          tail = pitchmarks(1) - round((fs/pitch)/2);
0051          candidateY = y(1:tail);
0052          [junk, newIndex] = min(candidateY);
0053          pitchmarks = [newIndex, pitchmarks];
0054       end;
0055       break;
0056    end;
0057    candidateY = y(minIndex:maxIndex);
0058    [junk, newIndex] = min(candidateY);
0059    pitchmarks = [minIndex+newIndex-1, pitchmarks];
0060 end
0061 
0062 %タpitch mark岿粇
0063 pitchmarks((diff(pitchmarks)==0)) = [];
0064 
0065 if plotopt,   
0066    plotpitchmarks(y, fs, pitchmarks, SFS_pitchcurve);
0067 end;
0068 
0069 
0070 % ============================================================== %
0071 % selfdemo
0072 % ============================================================== %
0073 function selfdemo
0074 wavefile = 'E:\test.wav';
0075 plotopt  = 1;
0076 [y, fs] = wavread(wavefile);
0077 
0078 % 璸衡 pitch
0079 SFS_pitchcurve = wave2pitch_SFS(wavefile);
0080 SFS_pitchcurve((SFS_pitchcurve<50 | SFS_pitchcurve>600)) = [];
0081 if isempty(SFS_pitchcurve), error('Pitch is not available!'); end;
0082 
0083 % 倒﹚ pitchmarkMIN 把计
0084 PitchMean = mean(SFS_pitchcurve);
0085 a = (1/PitchMean);
0086 b = a*0.5;
0087 maxPeriod = a + b;
0088 minPeriod = a - b;
0089 pitchmarks = feval(mfilename, y, fs, maxPeriod, minPeriod, SFS_pitchcurve, plotopt);

Generated on Tue 21-Aug-2007 22:52:24 by m2html © 2003