📄 dtwfixedpoint.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head> <title>Description of dtwFixedPoint</title> <meta name="keywords" content="dtwFixedPoint"> <meta name="description" content="dtwFixedPoint: Use of Picard iteration on finding the optimal pitch shift for DTW"> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <meta name="generator" content="m2html © 2003 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> > <a href="index.html">dcpr</a> > dtwFixedPoint.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td><td align="right"><a href="index.html">Index for dcpr <img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>dtwFixedPoint</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>dtwFixedPoint: Use of Picard iteration on finding the optimal pitch shift for DTW</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment"> dtwFixedPoint: Use of Picard iteration on finding the optimal pitch shift for DTW
Usage: [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt)
A typical example of param is
param.dtwFunc='dtw1mex';
param.anchorBeginning=1;
param.anchorEnd=0;
param.maxIterationNum=20;
allDist(i) is obtained as the DTW distance between inputPitch+allPitchShift(i) and dbPitch.
Type "dtwFixedPoint" for a self demo.</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="dtwFixedPoint.html" class="code" title="function [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt)">dtwFixedPoint</a> dtwFixedPoint: Use of Picard iteration on finding the optimal pitch shift for DTW</li><li><a href="dtwPlot.html" class="code" title="function dtwplot(vec1, vec2, DTWpath, DTWpath2)">dtwPlot</a> DTWPLOT Plot the result of DTW of two pitch/MFCC vectors</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="dtwFixedPoint.html" class="code" title="function [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt)">dtwFixedPoint</a> dtwFixedPoint: Use of Picard iteration on finding the optimal pitch shift for DTW</li></ul><!-- crossreference --><h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><ul style="list-style-image:url(../matlabicon.gif)"><li><a href="#_sub1" class="code">function selfdemo</a></li></ul><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt)</a>0002 <span class="comment">% dtwFixedPoint: Use of Picard iteration on finding the optimal pitch shift for DTW</span>0003 <span class="comment">% Usage: [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt)</span>0004 <span class="comment">% A typical example of param is</span>0005 <span class="comment">% param.dtwFunc='dtw1mex';</span>0006 <span class="comment">% param.anchorBeginning=1;</span>0007 <span class="comment">% param.anchorEnd=0;</span>0008 <span class="comment">% param.maxIterationNum=20;</span>0009 <span class="comment">%</span>0010 <span class="comment">% allDist(i) is obtained as the DTW distance between inputPitch+allPitchShift(i) and dbPitch.</span>0011 <span class="comment">%</span>0012 <span class="comment">% Type "dtwFixedPoint" for a self demo.</span>0013 0014 <span class="comment">% Roger Jang, 20080822</span>0015 0016 <span class="keyword">if</span> nargin<1, <a href="#_sub1" class="code" title="subfunction selfdemo">selfdemo</a>; <span class="keyword">return</span>; <span class="keyword">end</span>0017 <span class="keyword">if</span> nargin<3 | isempty(param)0018 param.dtwFunc=<span class="string">'dtw1mex'</span>;0019 param.anchorBeginning=1;0020 param.anchorEnd=0;0021 param.maxIterationNum=20;0022 <span class="keyword">end</span>0023 <span class="keyword">if</span> nargin<4, plotOpt=0; <span class="keyword">end</span>0024 0025 n=length(inputPitch);0026 0027 allDist=inf*ones(1, param.maxIterationNum); <span class="comment">% DTW distances for different pitch shifts</span>0028 endPos=zeros(1, param.maxIterationNum);0029 allPitchShift=zeros(1, param.maxIterationNum);0030 0031 allPitchShift(1)=median(dbPitch(1:n))-median(inputPitch);0032 thePitch=inputPitch+allPitchShift(1); <span class="comment">% Shift input pitch to have the same mean</span>0033 iterationNum=param.maxIterationNum; <span class="comment">% Actual number of iteration</span>0034 <span class="keyword">for</span> i=1:param.maxIterationNum0035 [allDist(i), dtwPath] = feval(param.dtwFunc, thePitch, dbPitch, param.anchorBeginning, param.anchorEnd);0036 endPos(i)=dtwPath(2,end);0037 shift=median(dbPitch(dtwPath(2, :))-thePitch(dtwPath(1, :)));0038 <span class="keyword">if</span> shift==00039 iterationNum=i;0040 <span class="keyword">break</span>;0041 <span class="keyword">end</span>0042 <span class="keyword">if</span> i==param.maxIterationNum0043 <span class="keyword">break</span>;0044 <span class="keyword">end</span>0045 allPitchShift(i+1)=allPitchShift(i)+shift;0046 thePitch=inputPitch+allPitchShift(i+1);0047 <span class="keyword">end</span>0048 allDist=allDist(1:iterationNum);0049 allPitchShift=allPitchShift(1:iterationNum);0050 minDist=min(allDist);0051 0052 <span class="keyword">if</span> plotOpt0053 subplot(3,1,1); plot(allDist(1:iterationNum), <span class="string">'.-'</span>); ylabel(<span class="string">'allDist'</span>);0054 subplot(3,1,2); plot(endPos(1:iterationNum), <span class="string">'.-'</span>); ylabel(<span class="string">'endPos'</span>);0055 subplot(3,1,3); plot(allPitchShift(1:iterationNum), <span class="string">'.-'</span>); ylabel(<span class="string">'allPitchShift'</span>);0056 xlabel(<span class="string">'Number of iterations'</span>);0057 figure; <a href="dtwPlot.html" class="code" title="function dtwplot(vec1, vec2, DTWpath, DTWpath2)">dtwPlot</a>(inputPitch, dbPitch, dtwPath);0058 fprintf(<span class="string">'Min. DTW distance = %f\n'</span>, minDist);0059 fprintf(<span class="string">'Optimum pitch shift = %f\n'</span>, allPitchShift(end));0060 <span class="keyword">end</span>0061 0062 <span class="comment">% ====== Self demo</span>0063 <a name="_sub1" href="#_subfunctions" class="code">function selfdemo</a>0064 <span class="comment">% inputPitch: input pitch vector</span>0065 inputPitch=[48.044247 48.917323 49.836778 50.154445 50.478049 50.807818 51.143991 51.486821 51.486821 51.486821 51.143991 50.154445 50.154445 50.154445 49.218415 51.143991 51.143991 50.807818 49.524836 49.524836 49.524836 49.524836 51.143991 51.143991 51.143991 51.486821 51.836577 50.807818 51.143991 52.558029 51.486821 51.486821 51.486821 51.143991 51.143991 51.143991 51.143991 51.143991 51.143991 51.143991 51.143991 51.143991 49.218415 50.807818 50.807818 50.154445 50.478049 48.044247 49.524836 52.193545 51.486821 51.486821 51.143991 50.807818 51.486821 51.486821 51.486821 51.486821 51.486821 55.788268 55.349958 54.922471 54.922471 55.349958 55.349958 55.349958 55.349958 55.349958 55.349958 55.349958 55.349958 53.699915 58.163541 59.213095 59.762739 59.762739 59.762739 59.762739 58.163541 57.661699 58.163541 58.680365 58.680365 58.680365 58.163541 55.788268 54.505286 55.349958 55.788268 55.788268 55.788268 54.922471 54.505286 56.237965 55.349958 55.349958 55.349958 55.349958 54.505286 54.505286 55.349958 48.917323 50.478049 50.807818 51.143991 51.143991 51.143991 50.807818 50.807818 50.478049 50.807818 51.486821 51.486821 51.486821 51.486821 51.486821 51.486821 52.558029 52.558029 52.558029 52.558029 52.193545 51.836577 52.193545 53.310858 53.310858 53.310858 52.930351 52.930351 53.310858 52.930351 52.558029 52.193545 52.930351 53.310858 52.930351 51.836577 52.558029 53.699915 52.930351 52.930351 52.558029 52.930351 52.930351 52.558029 52.558029 52.558029 53.310858 53.310858 53.310858 53.310858 52.930351 52.930351 52.930351 52.558029 52.930351 52.930351 52.930351 52.930351 52.930351 52.930351 52.930351 53.310858 53.310858 53.310858 52.193545 52.193545 52.193545 54.097918 52.930351 52.930351 52.930351 52.930351 52.930351 51.143991 51.143991 51.143991 48.917323 49.524836 49.524836 49.836778 49.524836 48.917323 49.524836 49.218415 48.330408 48.330408 48.330408 48.330408 48.330408 49.524836 49.836778 53.310858 53.310858 53.310858 52.930351 52.930351 52.930351 53.310858 52.930351 52.930351 52.558029 52.558029 51.143991 52.930351 49.218415 49.836778 50.154445 49.836778 49.524836 48.621378 48.621378 48.621378 49.836778 49.836778 49.836778 49.836778 46.680365 46.680365 46.680365 46.163541 45.661699 45.661699 45.910801 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 46.163541 50.807818 51.486821 51.486821 51.143991];0066 <span class="comment">% dbPitch: database pitch vector</span>0067 dbPitch =[60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 64 64 64 64 64 64 64 64 64 64 64 64 64 67 67 67 67 67 67 67 67 67 67 67 67 64 64 64 64 64 64 64 64 64 64 64 64 64 60 60 60 60 60 60 60 60 60 60 60 60 60 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 59 59 59 59 59 59 59 59 59 59 59 59 59 62 62 62 62 62 62 62 62 62 62 62 62 59 59 59 59 59 59 59 59 59 59 59 59 59 55 55 55 55 55 55 55 55 55 55 55 55 55 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 64 64 64 64 64 64 64 64 64 64 64 64 64 67 67 67 67 67 67 67 67 67 67 67 67 64 64 64 64 64 64 64 64 64 64 64 64 64 60 60 60 60 60 60 60 60 60 60 60 60 60 67 67 67 67 67 67 67 67 67 67 67 67 65 65 65 65 65 65 65 65 65 65 65 65 65 64 64 64 64 64 64 64 64 64 64 64 64 62 62 62 62 62 62 62 62 62 62 62 62 62 60 60 60 60 60 60 60 60 60 60 60 60 60];0068 [minDist, allDist, allPitchShift]=<a href="dtwFixedPoint.html" class="code" title="function [minDist, allDist, allPitchShift]=dtwFixedPoint(inputPitch, dbPitch, param, plotOpt)">dtwFixedPoint</a>(inputPitch, dbPitch, [], 1);</pre></div><hr><address>Generated on Thu 30-Oct-2008 12:53:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -