<?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>Detecting Notes or Chords</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2006/12/20 14:35:56.381 US/Central</md:created>
  <md:revised>2006/12/20 16:23:43.794 US/Central</md:revised>
  <md:authorlist>
      <md:author id="robsmith">
      <md:firstname>Rob</md:firstname>
      
      <md:surname>Smith</md:surname>
      <md:email>rob@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="robsmith">
      <md:firstname>Rob</md:firstname>
      
      <md:surname>Smith</md:surname>
      <md:email>rob@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>Chords</md:keyword>
    <md:keyword>FFT</md:keyword>
    <md:keyword>Guitar</md:keyword>
    <md:keyword>Notes</md:keyword>
  </md:keywordlist>

  <md:abstract>This module demonstrates how we use Matlab to determine if a guitar player is playing single notes or chords.</md:abstract>
</metadata>
  <content>
    <para id="delete_me">The input file is divided into 8000 sample lengths with each chunk being processed separately  For the 48kHz sample rate we used in our tests, that means each section is 1/6th of a second long.  The program takes the FFT of chunk and then uses a low pass filter to smooth out the peaks.</para><figure id="element-60"><name>FFT of Sample Chunk with Notes Marked</name>   <media type="image/png" src="FFT of Signal Chunk 6.png"/>   <caption>The program correctly detected the first note and found its harmonic.  There is one additional peak between the first note and its harmonic, so this is a two note chord.</caption></figure><para id="element-532">The peak detection works by finding the maximum value of the given signal, and then looking for areas where the signal is higher than 1/3rd of that maximum.  As the stems on the graph demonstrates, the program marks peaks on their falling edge, right as they pass back below the threshold.  This method works fairly well, but will sometimes miss a peak if it isn't as high as the threshold.  If I were to lower the threshold, however, noise would sometimes be counted as a peak.</para><figure id="element-10"><name>Number of Simultaneous Notes Over Song</name>   <media type="image/png" src="NotesPlayedOverSong.png"/>   <caption>The number of notes per chunk is recorded into a long vector which is returned back to the primary program.  This information is then used by the program to determine the appropriate effects levels.</caption></figure><figure id="element-471"><media type="file/m" src="findChord.m"/>
      	  <caption>This is the Matlab code for the function findChord.</caption></figure>   
  </content>
  
</document>
