0001 function waveCmPitchPlot(waveFile, xmlFile, pitchObj1, pitchObj2)
0002
0003
0004
0005
0006
0007
0008
0009 if nargin<1, selfdemo; return; end
0010
0011
0012 clf;
0013 subplot(2,1,1);
0014 waveCmPlot(waveFile, xmlFile);
0015 labelStr=waveFile;
0016 labelStr=strrep(labelStr, '\', '/'); labelStr=strrep(labelStr, '_', '\_');
0017 xlabel(labelStr);
0018
0019 pitch=pitchObj1.signal;
0020 [y, fs, nbits]=wavReadInt(waveFile);
0021 y=y(:,1);
0022 frameTime=frame2sampleIndex(1:length(pitch), fs/pitchObj1.frameRate, 0)/fs;
0023
0024 subplot(2,1,2);
0025 pitch(pitch==0)=nan;
0026 plot(frameTime, pitch, '.-');
0027 if nargin==3
0028 plot(frameTime, pitch, '.-');
0029 legend('Pitch');
0030 elseif nargin==4
0031 pitch2=pitchObj2.signal;
0032 pitch2(pitch2==0)=nan;
0033 frameTime2=frame2sampleIndex(1:length(pitch2), fs/pitchObj2.frameRate, 0)/fs;
0034 plot(frameTime, pitch, '.-', frameTime2, pitch2, 'o-r');
0035 legend('Pitch1', 'Pitch2');
0036 end
0037 ylabel('Pitch'); grid on;
0038 set(gca, 'xlim', [1, length(y)]/fs); set(gca, 'ylim', [-inf inf]);
0039
0040 waveObj.signal=y-mean(y); waveObj.fs=fs; waveObj.nbits=nbits;
0041 if nargin==3
0042 buttonH=wavePitchPlayButton(waveObj, pitchObj1);
0043 elseif nargin==4
0044 buttonH=wavePitchPlayButton(waveObj, pitchObj1, pitchObj2);
0045 end
0046
0047
0048 function selfdemo
0049 waveFile='囉哩囉唆令人不爽.wav';
0050 xmlFile='囉哩囉唆令人不爽.xml';
0051 pitchFile1='囉哩囉唆令人不爽1.pitch';
0052 pitchFile2='囉哩囉唆令人不爽2.pitch';
0053 [y, fs, nbits]=wavRead(waveFile);
0054
0055 frameSize=640; overlap=480;
0056 pitchObj1.frameRate=fs/(frameSize-overlap);
0057 pitchObj1.signal=asciiRead(pitchFile1);
0058
0059 frameSize=160; overlap=0;
0060 pitchObj2.frameRate=fs/(frameSize-overlap);
0061 pitchObj2.signal=freq2pitch(asciiRead(pitchFile2));
0062
0063 feval(mfilename, waveFile, xmlFile, pitchObj1, pitchObj2);