<?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>Modeling reverb in Matlab</name>
  <metadata>
  <md:version>1.2</md:version>
  <md:created>2006/12/18 02:48:11 US/Central</md:created>
  <md:revised>2006/12/23 13:58:05.874 US/Central</md:revised>
  <md:authorlist>
      <md:author id="brent">
      <md:firstname>Brent</md:firstname>
      <md:othername>E.</md:othername>
      <md:surname>Stephens</md:surname>
      <md:email>brents@rice.edu</md:email>
    </md:author>
      <md:author id="narayann">
      <md:firstname>Neil</md:firstname>
      <md:othername>K.</md:othername>
      <md:surname>Narayan</md:surname>
      <md:email>narayann@rice.edu</md:email>
    </md:author>
      <md:author id="robsmith">
      <md:firstname>Rob</md:firstname>
      
      <md:surname>Smith</md:surname>
      <md:email>rob@rice.edu</md:email>
    </md:author>
      <md:author id="barron">
      <md:firstname>Barron</md:firstname>
      <md:othername>D.</md:othername>
      <md:surname>Stone</md:surname>
      <md:email>barron@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="brent">
      <md:firstname>Brent</md:firstname>
      <md:othername>E.</md:othername>
      <md:surname>Stephens</md:surname>
      <md:email>brents@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="narayann">
      <md:firstname>Neil</md:firstname>
      <md:othername>K.</md:othername>
      <md:surname>Narayan</md:surname>
      <md:email>narayann@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="robsmith">
      <md:firstname>Rob</md:firstname>
      
      <md:surname>Smith</md:surname>
      <md:email>rob@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="barron">
      <md:firstname>Barron</md:firstname>
      <md:othername>D.</md:othername>
      <md:surname>Stone</md:surname>
      <md:email>barron@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="richb">
      <md:firstname>Richard</md:firstname>
      <md:othername>G.</md:othername>
      <md:surname>Baraniuk</md:surname>
      <md:email>richb@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="Markpanzee">
      <md:firstname>Mark</md:firstname>
      <md:othername>A.</md:othername>
      <md:surname>Davenport</md:surname>
      <md:email>md@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>guitar</md:keyword>
    <md:keyword>matlab</md:keyword>
    <md:keyword>reverb</md:keyword>
  </md:keywordlist>

  <md:abstract>A very simple reverb implementation in Matlab</md:abstract>
</metadata>
  <content>
    <para id="delete_me">Reverb with a guitar is exactly the same as creating reverb with any other sound signal.  This can be modeled with a difference equation of the form:</para><code type="block">a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb) - a(2)*y(n-1) - ... - a(na+1)*y(n-na)</code><para id="element-240">For this implementation, the difference equation I used had both feedback and feedforward delay.  The difference equation was:</para><code type="block">y(n) = gain * x(n) + x(n – delay) – gain * y(n – delay)</code><para id="element-804">In order to get the desired reverb effect, the guitar signal is passed through this difference three times with increasing delay.  This adds multiple delayed copies of the signal to the original signal.</para><para id="element-345">The Matlab code that implements this reverb is:</para><code type="block">function [output]=rev(sound, gain, delay)

output = sound;
d = delay * 5000;

for i = 1:3,
    b=[gain zeros(1,round(d/i)) 1];
    a=[1 zeros(1,round(d/i)) gain];
    output = filter(b, a, output);
end

output = sound + output;</code>   
  </content>
  
</document>
