<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="m10824">
  <name>Speech Processing: LPC Exercise in MATLAB</name>
  <metadata>
  <md:version>2.5</md:version>
  <md:created>2002/08/20</md:created>
  <md:revised>2003/08/01 11:48:40.661 GMT-5</md:revised>
  <md:authorlist>
    <md:author id="appadwed">
      <md:firstname>Swaroop</md:firstname>
      
      <md:surname>Appadwedula</md:surname>
      <md:email>appadwed@uiuc.edu</md:email>
    </md:author>
    <md:author id="dljones">
      <md:firstname>Douglas</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Jones</md:surname>
      <md:email>dl-jones@uiuc.edu</md:email>
    </md:author>
    <md:author id="kramer">
      <md:firstname>Michael</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Kramer</md:surname>
      <md:email>kramer@ifp.uiuc.edu</md:email>
    </md:author>
    <md:author id="moussa">
      <md:firstname>Dima</md:firstname>
      
      <md:surname>Moussa</md:surname>
      <md:email>dmoussa@uiuc.edu</md:email>
    </md:author>
    <md:author id="bwade">
      <md:firstname>Brian</md:firstname>
      
      <md:surname>Wade</md:surname>
      <md:email>bwade@uiuc.edu</md:email>
    </md:author>
    <md:author id="jake">
      <md:firstname>Jake</md:firstname>
      
      <md:surname>Janevitz</md:surname>
      <md:email>jake@janevitz.com</md:email>
    </md:author>
    <md:author id="dsachs">
      <md:firstname>Daniel</md:firstname>
      <md:othername>Grobe</md:othername>
      <md:surname>Sachs</md:surname>
      <md:email>sachs@uiuc.edu</md:email>
    </md:author>
    <md:author id="mjberry">
      <md:firstname>Matthew</md:firstname>
      <md:othername>J.</md:othername>
      <md:surname>Berry</md:surname>
      <md:email>mjberry@uiuc.edu</md:email>
    </md:author>
    <md:author id="markhaun">
      <md:firstname>Mark</md:firstname>
      <md:othername>A.</md:othername>
      <md:surname>Haun</md:surname>
      <md:email>markhaun@uiuc.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="mjberry">
      <md:firstname>Matthew</md:firstname>
      <md:othername>J.</md:othername>
      <md:surname>Berry</md:surname>
      <md:email>mjberry@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="butala">
      <md:firstname>Mark</md:firstname>
      <md:othername>D.</md:othername>
      <md:surname>Butala</md:surname>
      <md:email>butala@uiuc.edu</md:email>
    </md:maintainer>
    <md:maintainer id="rlmorris">
      <md:firstname>Robert</md:firstname>
      <md:othername>L.</md:othername>
      <md:surname>Morrison</md:surname>
      <md:email>rlmorris@uiuc.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>linear predictive coding</md:keyword>
    <md:keyword>autocorrelation</md:keyword>
    <md:keyword>xcorr</md:keyword>
    <md:keyword>levinson-durbin algorithm</md:keyword>
    <md:keyword>speech</md:keyword>
    <md:keyword>speech analysis</md:keyword>
    <md:keyword>speech synthesis</md:keyword>
    <md:keyword>speech coding</md:keyword>
    <md:keyword>speech compression</md:keyword>
    <md:keyword>DSP</md:keyword>
  </md:keywordlist>

  <md:abstract>You will write MATLAB code to compute the autocorrelation sequence of a simple signal.  Then you will implement the Levinson-Durbin algorithm in MATLAB and analyze a recording of your own voice.  </md:abstract>
</metadata>




  <content>
    <section id="section2">
      <name>MATLAB Exercises</name>



      <para id="prob1">
	First, take a simple signal (<foreign>e.g.</foreign>, one
	period of a sinusoid at some frequency) and plot its
	autocorrelation sequence for appropriate values of
	<m:math>
	  <m:ci>l</m:ci>
	</m:math>. You may wish to use the <code>xcorr</code> MATLAB
	function to compare with your own version of this function.
	At what time shift 
	<m:math>
	  <m:ci>l</m:ci>
	</m:math> is
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">
	      <m:msub>
		<m:mi>r</m:mi>
		<m:mrow>
		  <m:mi>s</m:mi>
		  <m:mi>s</m:mi>
		</m:mrow>
	      </m:msub>
	    </m:ci>
	    <m:ci>l</m:ci>
	  </m:apply>
	</m:math> maximized and why?  Is there any symmetry in
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">
	      <m:msub>
		<m:mi>r</m:mi>
		<m:mrow>
		  <m:mi>s</m:mi>
		  <m:mi>s</m:mi>
		</m:mrow>
	      </m:msub>
	    </m:ci>
	    <m:ci>l</m:ci>
	  </m:apply>
	</m:math>?  What does
	<m:math>
	  <m:apply>
	    <m:ci type="fn" class="discrete">
	      <m:msub>
		<m:mi>r</m:mi>
		<m:mrow>
		  <m:mi>s</m:mi>
		  <m:mi>s</m:mi>
		</m:mrow>
	      </m:msub>
	    </m:ci>
	    <m:ci>l</m:ci>
	  </m:apply>
	</m:math> look like for periodic signals?
      </para>

      <para id="prob2">
	Next, write your own version of the Levinson-Durbin algorithm
	in MATLAB.  Note that MATLAB uses indexing from
	<m:math>
	  <m:cn>1</m:cn>
	</m:math> rather than
	<m:math>
	  <m:cn>0</m:cn>
	</m:math>.  One way to resolve this problem is to start the
	loop with
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>i</m:ci>
	    <m:cn>2</m:cn>
	  </m:apply>
	</m:math>, then shift the variables
	<m:math>
	  <m:ci>k</m:ci>
	</m:math>,
	<m:math>
	  <m:ci>E</m:ci>
	</m:math>,
	<m:math>
	  <m:ci>α</m:ci>
	</m:math>, and
	<m:math>
	  <m:ci>
	    <m:msub>
	      <m:mi>r</m:mi>
	      <m:mrow>
		<m:mi>s</m:mi>
		<m:mi>s</m:mi>
	      </m:mrow>
	    </m:msub>
	  </m:ci>
	</m:math> to start at 
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>i</m:ci>
	    <m:cn>1</m:cn>
	  </m:apply>
	</m:math> and 
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>j</m:ci>
	    <m:cn>1</m:cn>
	  </m:apply>
	</m:math>. Be careful with indices such as 
	<m:math>
	  <m:apply>
	    <m:minus/>
	    <m:ci>i</m:ci>
	    <m:ci>j</m:ci>
	  </m:apply>
	</m:math>, since these could 
	still be 
	<m:math>
	  <m:cn>0</m:cn>
	</m:math>.  
      </para>

      <para id="para11">
	Apply your algorithm to a 
	<m:math>
	  <m:cn>20</m:cn>
	</m:math>-
	<m:math>
	  <m:cn>30</m:cn>
	</m:math> ms segment of a speech signal.  Use a microphone to
	record <code>.wav</code> audio files on the PC using Sound
	Recorder or a similar application.  Typically, a sample rate
	of 
	<m:math>
	  <m:cn>8</m:cn>
	</m:math> kHz is a good choice for voice signals, which are
	approximately bandlimited to 
	<m:math>
	  <m:cn>4</m:cn>
	</m:math>
	kHz.  You will use these audio files to test algorithms in
	MATLAB.  The functions <code>wavread</code>,
	<code>wavwrite</code>, <code>sound</code> will help you read,
	write and play audio files in MATLAB:
	
      </para>

      <para id="para12">
	The output of the algorithm is the prediction coefficients

 	<m:math>
	  <m:ci>
	    <m:msub>
	      <m:mi>a</m:mi>
	      <m:mi>k</m:mi>
	    </m:msub>
	  </m:ci>
	</m:math> (usually about 
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>P</m:ci>
	    <m:cn>10</m:cn>
	  </m:apply>
	</m:math> coefficients is sufficient), which represent the
	speech segment containing significantly more samples.  The LPC
	coefficients are thus a compressed representation of the
	original speech segment, and we take advantage of this by
	saving or transmitting the LPC coefficients instead of the
	speech samples.  Compare the coefficients generated by your
	function with those generated by the <code>levinson</code> or
	<code>lpc</code> functions available in the MATLAB toolbox.
	Next, plot the frequency response of the IIR model represented
	by the LPC coefficients (see <cnxn document="m10482" target="eq5">Speech Processing: Theory of LPC Analysis and
	Synthesis</cnxn>).  What is the fundamental frequency of the
	speech segment?  Is there any similarity in the prediction
	coefficients for different
	<m:math>
	  <m:cn>20</m:cn>
	</m:math>-
	<m:math>
	  <m:cn>30</m:cn>
	</m:math>
	ms segments of the same vowel sound?  How could the prediction
	coefficients be used for recognition?
      </para>
    </section>
    
  </content>
  
</document>
