Reverb and the Convolution Theorem
Copyright © 2004-2007 Stephen G. McGovern
email:



In order to simulate reverb one first needs two things, an impulse response and a sound. Rather than a smooth waveform, we will represent our sound and impulse response by a string of numbers. Each number will represent the magnitude of the smooth waveform at specific instances in time. Now let's say that we have a sound represented by the vector x[n] as given below.

x[n] = [1, 3, 5, 2]

Let's also say that we have an impulse response given by the vector h[n] as shown below.

h[n] = [2, 8, 6]

The operation that we need to perform is called a convolution. There are several steps in convoluting two vectors. We can start by multiplying x[n] by the first term in h[n], as illustrated below

x[n]*h[1]= [1, 3, 5, 2]*[2] = [2, 6, 10, 4]

Next we delay our signal x[n] by one, so that we get:

x[n-1]= [0, 1, 3, 5, 2]

And then we multiply it by the second term in h[n] so that we get:

x[n-1]*h[2]= [0, 1, 3, 5, 2]*[8] = [0, 8, 24, 40, 16]

This procedure is repeated once again to give:

x[n-2]*h[3]= [0, 0, 1, 3, 5, 2]*[6]=[0, 0, 6, 18, 30, 12]

We have to stop here because there are no more values of h[n]. Now lets line up our three vectors

[2, 6, 10,  4]        
[0, 8, 24, 40, 16]    
[0, 0,  6, 18, 30, 12]

If we postpend zeros to the first and second columns we get:

[2, 6, 10,  4,  0,  0]
[0, 8, 24, 40, 16,  0]
[0, 0,  6, 18, 30, 12]

Now we sum along each column and get:

[2, 14, 40, 62, 46, 12]

This result is known as the convolution of h[n] with x[n]. The convolution operation can be written as (Mitra, page 72):


Unfortunately our x and h vectors could easily be of length 2,880,000 and 150,000 respectively. When using vectors of this size the above operation is prohibitively slow. To circumvent this problem we use an equivalent operation. We take the Fourier transforms of both x[n] and h[n], multiply the results together, and then take the inverse Fourier transform. Taking the real part yields y[n] again. Just as in the above equation this is also the convolution of h[n] with x[n].


In the above equation Γ(x) and Γ(h) are the Fourier transforms of x[n] and h[n] respectively. Γ<i> represents an inverse Fourier transform. Convolutions found by this procedure are known by the term "fast convolution."



FCONV.m - Matlab function to convolve two vectors. For documentation put this in your Matlab work folder and type "help fconv" at the Matlab command prompt.
FDECONV.m - Matlab function to deconvolve one vector from another. For documentation put this in your Matlab work folder and type "help fdeconv" at the Matlab command prompt.

home




Bibliography


Sanjit Mitra.
Digital Signal Processing,
A Computer-Based Approach.
McGraw-Hill, 2nd edition, 2001.

R.B. Randall.
Application of B&K Equipment to Frequency Analysis.
Brüel & Kjær, NÆrum, Denmark, 2nd edition, 1977

Eric W. Weisstein.
"Convolution." From MathWorld--A Wolfram Web Resource.
http://mathworld.wolfram.com/Convolution.html

Eric W. Weisstein.
"Convolution Theorem." From MathWorld--A Wolfram Web Resource.
http://mathworld.wolfram.com/ConvolutionTheorem.html

Udo Zolzer.
DAFX, Digital Audio Effects.
Wiley, 2002.