Add reverberation to audio signal
System object™ adds reverberation to mono or stereo audio signals.
To add reverberation to your input:
reverberator object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?.
reverb = reverberator creates a System object,
reverb, that adds artificial reverberation to an audio
reverb = reverberator( sets each
Name to the specified
Unspecified properties have default values.
reverb = reverberator('PreDelay',0.5,'WetDryMix',1)creates a System object,
reverb, with a 0.5 second pre-delay and a wet-to-dry mix ratio of one.
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
PreDelay— Pre-delay for reverberation (s)
0(default) | real positive scalar
Pre-delay for reverberation in seconds, specified as a real scalar in the range [0, 1].
Pre-delay for reverberation is the time between hearing
direct sound and the first early reflection. The value of
is proportional to the size of the room being modeled.
HighCutFrequency— Lowpass filter cutoff (Hz)
20000(default) | real positive scalar
Lowpass filter cutoff in Hz, specified as a real positive scalar in the range 0 to .
Lowpass filter cutoff is the –3 dB cutoff frequency for the single-pole lowpass filter at the front of the reverberator structure. It prevents the application of reverberation to high-frequency components of the input.
Diffusion— Density of reverb tail
0.5(default) | real scalar
Density of reverb tail, specified as a real positive scalar in the range [0, 1].
Diffusion is proportional to the rate at which the reverb tail
builds in density. Increasing
Diffusion pushes the reflections
closer together, thickening the sound. Reducing
more discrete echoes.
DecayFactor— Decay factor of reverb tail
0.5(default) | real scalar
Decay factor of reverb tail, specified as a real positive scalar in the range [0, 1].
DecayFactor is proportional to the time it takes for
reflections to run out of energy. To model a large room, use a long reverb tail (low
decay factor). To model a small room, use a short reverb tail (high decay
HighFrequencyDamping— High-frequency damping
0.0005(default) | real scalar
High-frequency damping, specified as a real positive scalar in the range [0, 1].
HighFrequencyDamping is proportional to the attenuation of high
frequencies in the reverberation output. Setting
HighFrequencyDamping to a large value makes high-frequency
reflections decay faster than low-frequency reflections.
WetDryMix— Wet-dry mix
0.3(default) | real scalar
Wet-dry mix, specified as a real positive scalar in the range [0, 1].
Wet-dry mix is the ratio of wet (reverberated) to dry
(original) signal that your
System object outputs.
SampleRate— Input sample rate (Hz)
44100(default) | positive scalar
Input sample rate in Hz, specified as a positive scalar.
audioIn— Audio input to reverberator
Audio input to the reverberator, specified as a column vector or two-column matrix. The columns of the matrix are treated as independent audio channels.
audioOut— Audio output from reverberator
Audio output from the reverberator, returned as a two-column matrix.
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named
reverberator System object™ to add artificial reverberation to an audio signal read from a file.
audioDeviceWriter System objects. Use the sample rate of the reader as the sample rate of the writer.
fileReader = dsp.AudioFileReader('FunkyDrums-44p1-stereo-25secs.mp3','SamplesPerFrame',1024); deviceWriter = audioDeviceWriter('SampleRate',fileReader.SampleRate);
Play 10 seconds of the audio signal through your device.
tic while toc < 10 audio = fileReader(); deviceWriter(audio); end release(fileReader)
reverberator System object with default settings.
reverb = reverberator
reverb = reverberator with properties: PreDelay: 0 HighCutFrequency: 20000 Diffusion: 0.5000 DecayFactor: 0.5000 HighFrequencyDamping: 5.0000e-04 WetDryMix: 0.3000 SampleRate: 44100
Construct a time scope to visualize the original audio signal and the audio signal with added artificial reverberation.
scope = timescope( ... 'SampleRate',fileReader.SampleRate,... 'TimeSpanOverrunAction','Scroll',... 'TimeSpanSource','property',... 'TimeSpan',3,... 'BufferLength',3*fileReader.SampleRate*2, ... 'YLimits',[-1,1],... 'ShowGrid',true, ... 'ShowLegend',true, ... 'Title','Audio with Reverberation vs. Original');
Play the audio signal with artificial reverberation. Visualize the audio with reverberation and the original audio.
while ~isDone(fileReader) audio = fileReader(); audioWithReverb = reverb(audio); deviceWriter(audioWithReverb); scope([audioWithReverb(:,1),audio(:,1)]) end release(fileReader) release(deviceWriter) release(scope)
dsp.AudioFileReader to read in audio frame-by-frame. Create an
audioDeviceWriter to write audio to your sound card. Create a
reverberator to process the audio data.
frameLength = 1024; fileReader = dsp.AudioFileReader('RockDrums-44p1-stereo-11secs.mp3', ... 'SamplesPerFrame',frameLength,'PlayCount',2); deviceWriter = audioDeviceWriter('SampleRate',fileReader.SampleRate); reverb = reverberator('SampleRate',fileReader.SampleRate);
parameterTuner to open a UI to tune parameters of the
octaveFilter while streaming.
In an audio stream loop:
Read in a frame of audio from the file.
Write the frame of audio to your audio device for listening.
While streaming, tune parameters of the reverberator and listen to the effect.
while ~isDone(fileReader) audioIn = fileReader(); audioOut = reverb(audioIn); deviceWriter(audioOut); drawnow limitrate % required to update parameter end
As a best practice, release your objects once done.
release(deviceWriter) release(fileReader) release(reverb)
The algorithm to add reverberation follows the plate-class reverberation topology described in  and is based on a 29,761 Hz sample rate.
The algorithm has five stages.
The description for the algorithm that follows is for a stereo input. A mono input is a simplified case.
A stereo signal is converted to a mono signal: .
A delay followed by a lowpass filter preconditions the mono signal.
The pre-delay output is determined as , where the
PreDelay property determines the value
The signal is fed through a single-pole lowpass filter with transfer function
fc is the cutoff frequency specified
fs is the sampling frequency specified
The signal is decorrelated by passing through a series of four allpass filters.
The allpass filters are of the form
where β is the coefficient specified by the
Diffusion property and k is the delay as follows:
For AP1, k = 142.
For AP2, k = 107.
For AP3, k = 379.
For AP4, k = 277.
The signal is fed into the tank, where it circulates to simulate the decay of a reverberation tail.
The following description tracks the signal as it progresses through the top of the tank. The signal progression through the bottom of the tank follows the same pattern, with different delay specifications.
The new signal enters the top of the tank and is added to the circulated signal from the bottom of the tank.
The signal passes through a modulated allpass filter:
β is the coefficient specified by the
k is the variable delay specified by a 1 Hz sinusoid with
amplitude = (8/29761) *
account for fractional delay resulting from the modulating k,
allpass interpolation is used .
The signal is delayed again, and then passes through a lowpass filter:
φ is the coefficient specified by the
The signal is multiplied by a gain specified by the
property. The signal then passes through an allpass filter:
β is the coefficient specified by the
k is set to
1800 for the top of the tank
2656 for the bottom of the tank.
The signal is delayed again and then circulated to the bottom half of the tank for the next iteration.
A similar pattern is executed in parallel for the bottom half of the tank. The output
of the tank is calculated as the signed sum of delay lines picked off at various points from
the tank. The summed output is multiplied by
The wet (processed) signal is then added to the dry (original) signal:
WetDryMix property determines
 Dattorro, Jon. "Effect Design, Part 1: Reverberator and Other Filters." Journal of the Audio Engineering Society. Vol. 45, Issue 9, 1997, pp. 660–684.
 Dattorro, Jon. "Effect Design, Part 2: Delay-Line Modulation and Chorus." Journal of the Audio Engineering Society. Vol. 45, Issue 10, 1997, pp. 764–788.
Usage notes and limitations:
System Objects in MATLAB Code Generation (MATLAB Coder)