Connexions

You are here: Home » Content » Modeling reverb in Matlab
Content Actions

Modeling reverb in Matlab

Module by: Brent Stephens, Neil Narayan, Rob Smith, Barron Stone

Summary: A very simple reverb implementation in Matlab

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:
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)
For this implementation, the difference equation I used had both feedback and feedforward delay. The difference equation was:
y(n) = gain * x(n) + x(n – delay) – gain * y(n – delay)
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.
The Matlab code that implements this reverb is:
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;

Comments, questions, feedback, criticisms?

Discussion forum

Send feedback