<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/technology/cnxml/schema/dtd/0.5/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" xmlns:m="http://www.w3.org/1998/Math/MathML" id="new">
  <name>Karplus-Strong Plucked String Algorithm</name>
  <metadata>
  <md:version>1.2</md:version>
  <md:created>2007/09/28 08:02:50 GMT-5</md:created>
  <md:revised>2008/03/18 09:43:22.513 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="doering">
      <md:firstname>Ed</md:firstname>
      
      <md:surname>Doering</md:surname>
      <md:email>doering@rose-hulman.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="doering">
      <md:firstname>Ed</md:firstname>
      
      <md:surname>Doering</md:surname>
      <md:email>doering@rose-hulman.edu</md:email>
    </md:maintainer>
    <md:maintainer id="eluther">
      <md:firstname>Erik</md:firstname>
      <md:othername>B</md:othername>
      <md:surname>Luther</md:surname>
      <md:email>erik.luther@ni.com</md:email>
    </md:maintainer>
    <md:maintainer id="SShearman">
      <md:firstname>Sam</md:firstname>
      <md:othername>D.</md:othername>
      <md:surname>Shearman</md:surname>
      <md:email>sam.shearman@ni.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>Alex Strong</md:keyword>
    <md:keyword>delay line</md:keyword>
    <md:keyword>Kevin Karplus</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>lowpass filter</md:keyword>
    <md:keyword>MIDI JamSession</md:keyword>
    <md:keyword>plucked string algorithm</md:keyword>
    <md:keyword>virtual musical instrument</md:keyword>
    <md:keyword>white noise burst</md:keyword>
  </md:keywordlist>

  <md:abstract>The Karplus-Strong algorithm plucked string algorithm produces remarkably realistic tones with modest computational effort. The algorithm requires a delay line and lowpass filter arranged in a closed loop, which can be implemented as a single digital filter. The filter is driven by a burst of white noise to initiate the sound of the plucked string. Learn about the Karplus-Strong algorithm and how to implement it as a LabVIEW "virtual musical instrument" (VMI) to be played from a MIDI file using "MIDI JamSession."</md:abstract>
</metadata>

<content>

<table id="labview_banner" frame="none"><tgroup cols="2">
<colspec rowsep="0" colsep="0"/> <colspec colwidth="6in" rowsep="0" colsep="0"/>
<tbody>
  <row>
    <entry morerows="3"><media type="image/png" src="LabVIEWq.png"/></entry>
    <entry> This module refers to LabVIEW, a software development environment that features a graphical programming language.
       Please see the <cnxn document="m15428">LabVIEW QuickStart Guide</cnxn> module for tutorials and documentation that will help you:</entry>
  </row>
  <row> <entry>• Apply LabVIEW to Audio Signal Processing </entry> </row>
  <row> <entry>• Get started with LabVIEW</entry> </row>
  <row> <entry>• Obtain a fully-functional evaluation edition of LabVIEW</entry> </row>
</tbody>
</tgroup>
</table>


<section id="sec1">
<name>Introduction</name>

<para id="par2">
		In 1983 Kevin Karplus and Alex Strong published an algorithm to emulate the sound of a plucked string (see "References" section).
		The Karplus-Strong algorithm produces remarkably realistic tones with modest computational effort.</para>

<para id="par3">		As an example, consider the sound of a violin's four strings plucked in succession: 
		<link src="violin_plucked.wav">violin_plucked.wav</link> (compare to the same four strings bowed instead of 
		plucked: <link src="violin_bowed.wav">violin_bowed.wav</link>). Now compare to the Karplus-Strong 
		version of the same four pitches: <link src="ks_plucked.wav">ks_plucked.wav</link>.</para>

<para id="par4">		In this module, learn about the Karplus-Strong plucked string algorithm and how to create
		a LabVIEW virtual musical instrument (VMI) that you can "play" using a MIDI music file.
</para>

</section>

<section id="sec5">
<name>Karplus-Strong Algorithm</name>

<para id="par6">
		The <cnxn target="video-theory"/> screencast video develops the theory of the Karplus-Strong
		plucked string algorithm, which is based on a closed loop composed of a delay line and a low pass filter.
		As will be shown, the delay line is initialized with a noise burst, and the continuously circulating
		noise burst is filtered slightly on each pass through the loop. The output signal is therefore quasi-periodic
		with a wideband noise-like transient converging to a narrowband signal composed of only a few sinusoidal
		harmonic components.
</para>

<figure id="video-theory">
<media type="image/png" src="sub_ks-theory.html">
   <param name="thumbnail" value="sub_ks-theory.png"/>
   </media>
<caption>
   [video] Theory of the Karplus-Strong plucked string algorithm
</caption>
</figure>

</section>

<section id="sec8">
<name>LabVIEW Implementation</name>

<para id="par9">
		The Karplus-Strong algorithm block diagram may be viewed as a <emphasis>single</emphasis> digital filter 
		that is excited by a noise pulse. For real-time implementation, the digital filter runs continuously with
		an input that is normally zero. The filter is "plucked" by applying a burst of white noise that is long
		enough to completely fill the delay line.</para>

<para id="par10">		As an exercise, review the block diagram shown in <cnxn target="video-theory"/> and derive
		the difference equation that relates the overall output y(n) to the input x(n). Invest some effort in
		this so that you can develop a better understanding of the algorithm. Watch the video solution in
		<cnxn target="video-diffeqn"/> only <emphasis>after</emphasis> you have completed your own
		derivation.
</para>

<figure id="video-diffeqn">
<media type="image/png" src="sub_ks-diffeqn.html">
   <param name="thumbnail" value="sub_ks-diffeqn.png"/>
   </media>
<caption>
   [video] Difference equation for Karplus-Strong block diagram
</caption>
</figure>

<para id="par12">
		The <cnxn target="video-build"/> screencast video shows how to implement the difference
		equation as a digital filter and how to create the noise pulse. The video includes an audio 
		demonstration of the finished result.
</para>

<figure id="video-build">
<media type="image/png" src="sub_ks-build.html">
   <param name="thumbnail" value="sub_ks-build.png"/>
   </media>
<caption>
   [video] Building the Karplus-Strong block diagram in LabVIEW
</caption>
</figure>

</section>

<section id="sec14">
<name>Project Activity: Karplus-Strong VMI</name>

<para id="par15">
		In order to better appreciate the musical qualities of the Karplus-Strong plucked string algorithm, 
		convert the algorithm to a <term>virtual musical instrument</term> (<term>VMI</term> for short) 
		that can be played by "MIDI Jam Session." If necessary, visit 
		<cnxn document="m15053">MIDI Jam Session</cnxn>, download the application VI .zip file, and view the 
		screencast video in that module to learn more about the application and how to create your 
		own virtual musical instrument. Your VMI will accept parameters that specify 
		frequency, amplitude, and duration of a single note, and will produce a corresponding array of 
		audio samples using the Karplus-Strong algorithm described in the previous section.</para>

<para id="par16">		For best results, select a MIDI music file that contains a solo instrument or perhaps a duet.
		For example, try "Sonata in A Minor for Cello and Bass Continuo" by Antonio Vivaldi. 
		A MIDI version of the sonata is available at the 
		<link src="http://www.classicalguitarmidi.com">Classical Guitar MIDI Archives</link>, specifically 
		<link src="http://www.classicalguitarmidi.com/subivic/Vivaldi_Sonata_Cello_Bass.mid">Vivaldi_Sonata_Cello_Bass.mid</link>.</para>

<para id="par17">
		Try experimenting with the critical parameters of your instrument, including sampling frequency and
		the low-pass filter constant
<m:math>
 <m:semantics>
  <m:mi>g</m:mi>
 <m:annotation encoding="MathType-MTEF">
 MathType@MTEF@5@5@+=feaagaart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYb1uaebbnrfifHhDYfgasaacH8srps0lbbf9q8WrFfeuY=Hhbbf9v8qqaqFr0xc9pk0xbba9q8WqFfea0=yr0RYxir=Jbba9q8aq0=yq=He9q8qqQ8frFve9Fve9Ff0dmeaabaqaciGacaGaaeqabaWaaeaaeaaakeaacaWGNbaaaa@3633@</m:annotation>
 </m:semantics>
</m:math>.  Regarding sampling frequency: lower sampling frequencies influence
		the sound in <emphasis>two</emphasis> distinct ways -- can you describe each of these two ways?
</para>

</section>

<section id="sec18">
<name>References</name>

<list id="list19" type="bulleted">

<item> Moore, F.R., "Elements of Computer Music," Prentice-Hall, 1990, ISBN 0-13-252552-6. </item>
<item> Karplus, K., and A. Strong, "Digital Synthesis of Plucked String and Drum Timbres," 
			Computer Music Journal 7(2): 43-55, 1983. </item>

</list>

</section>

</content>
</document>
