FX Class: Reverb

Interactive example


Overview

This CPU-friendly reverb audio effect outputs adds depth to the sound, putting the audio into a virtual enclosed space, reflecting in all directions, decaying in amplitude, and eventually dying off as the sound is absorbed by the surfaces of objects in the space. One instance allocates around 120 kb memory.

The mix property is used to edit and control the balance of the original signal ("dry") and the affected signal ("wet") leaving the reverb, however they can also be adjusted in detail using dry and wet.

The roomSize property controls the scale of the decay time and reflections found in the physical characteristics of living spaces, and studios. A large room size results in longer reverb time, providing the illusion of a physically larger space. The predelayMs property is the length of time it takes for a sound wave to leave its source and create its first reflection is determined by the pre-delay. This property controls an offset of reverb from the dry signal. An increase in pre-delay can result in a feeling of a bigger space too.

The damp property is used to control the absorption of high frequencies in the reverb. More absorption of high frequencies means higher damping values. The tail of the reverb will lose high frequencies as they bounce around softer surfaces like halls and result in warmer sounds. The lowCutHz property controls the low frequency build up generated from the reverb. This can be used to shape the output of the reverb, and to limit the rumbling sound of low frequency content.

width allows for the expanding or collapsing the stereo width of the reverberation.

Implementation example

class SuperpoweredReverbProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor {
onReady() {
this.reverb = new this.Superpowered.Reverb(
this.samplerate, // The initial sample rate in Hz.
44100 // Maximum sample rate (affects memory usage, the lower the smaller).
);
this.reverb.enabled = true;
}
// Runs before the node is destroyed.
// Clean up memory and objects here (such as free allocated linear memory or destruct Superpowered objects).
onDestruct() {
this.reverb.destruct();
}
onMessageFromMainScope(message) {
if (typeof message.dry !== 'undefined') this.revberb.dry = message.dry;
if (typeof message.wet !== 'undefined') this.reverb.wet = message.wet;
if (typeof message.mix !== 'undefined') this.reverb.mix = message.mix;
if (typeof message.width !== 'undefined') this.reverb.width = message.width;
if (typeof message.damp !== 'undefined') this.reverb.damp = message.damp;
if (typeof message.roomSize !== 'undefined') this.reverb.roomSize = message.roomSize;
if (typeof message.predelayMs !== 'undefined') this.reverb.predelayMs = message.predelayMs;
if (typeof message.lowCutHz !== 'undefined') this.reverb.lowCutHz = message.lowCutHz;
}
// This is the process loop which is passed pointers to audio buffers
// from the WebAudio API (inputBuffer and outputBuffer), with the buffersize
processAudio(inputBuffer, outputBuffer, buffersize) {
// Ensure the samplerate is in sync on every audio processing callback
this.reverb.samplerate = this.samplerate;
// Render the output buffers
if (!this.reverb.process(inputBuffer.pointer, outputBuffer.pointer, buffersize)) {
for (let n = 0; n < buffersize * 2 ; n++) outputBuffer.array[n] = inputBuffer.array[n];
}
}
}
#include "SuperpoweredReverb.h"
void initReverbEffect() {
const unsigned int sampleRate = 44100;
const unsigned int maxSampleRate = 96000;
reverb = new Superpowered::Reverb(sampleRate, maxSampleRate);
reverb->enabled = true;
}
void configureReverbEffect() {
reverb->dry = 0.987;
reverb->wet = 0.587;
reverb->mix = 0.4;
reverb->width = 1;
reverb->damp = 0.5;
reverb->roomSize = 0.8;
reverb->predelayMs = 0;
reverb->lowCutHz = 0;
}
void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) {
// Ensure the samplerate is in sync on every audio processing callback
reverb->samplerate = samplerate;
// Render the output buffers
bool outputChanged = reverb->process(interleavedInput, interleavedOutput, numberOfFrames);
...
}

Properties

damp

PROPERTY
Used to control the absorption of high frequencies in the reverb. More absorption of high frequencies means higher damping values. The tail of the reverb will lose high frequencies as they bounce around softer surfaces like halls and result in warmer sounds.
TypeMinMaxDefault
Number
010.5

damp

PROPERTY
Used to control the absorption of high frequencies in the reverb. More absorption of high frequencies means higher damping values. The tail of the reverb will lose high frequencies as they bounce around softer surfaces like halls and result in warmer sounds.
TypeMinMaxDefault
float
010.5

dry

PROPERTY
Loudness of the dry signal. Don't use the mix property when using the dry and wet properties.
TypeMinMaxDefault
Number
010.987

dry

PROPERTY
Loudness of the dry signal. Don't use the mix property when using the dry and wet properties.
TypeMinMaxDefault
float
010.987

lowCutHz

PROPERTY
Frequency of the low cut in Hz (-12 db point). Controls the low frequency build up generated from the reverb.
TypeMinMaxDefault
Number
0sample rate / 20 (no low frequency cut)

lowCutHz

PROPERTY
Frequency of the low cut in Hz (-12 db point). Controls the low frequency build up generated from the reverb.
TypeMinMaxDefault
float
0sample rate / 20 (no low frequency cut)

mix

PROPERTY
Sets dry and wet simultaneously with a nice balanced power curve. Don't use the dry and wet properties while using mix.
TypeMinMaxDefault
Number
010.4

mix

PROPERTY
Sets dry and wet simultaneously with a nice balanced power curve. Don't use the dry and wet properties while using mix.
TypeMinMaxDefault
float
010.4

predelayMs

PROPERTY
Pre-delay in milliseconds. The length of time it takes for a sound wave to leave its source and create its first reflection is determined by the pre-delay. This property controls the offset of reverb from the dry signal. An increase in pre-delay can result in a feeling of a bigger space.
TypeMinMaxDefault
Number
05000

predelayMs

PROPERTY
Pre-delay in milliseconds. The length of time it takes for a sound wave to leave its source and create its first reflection is determined by the pre-delay. This property controls the offset of reverb from the dry signal. An increase in pre-delay can result in a feeling of a bigger space.
TypeMinMaxDefault
float
05000

roomSize

PROPERTY
Room size controls the scale of the decay time and reflections found in the physical characteristics of living spaces, and studios. These unique attributes will simulate the expected behavior of acoustic environments. A larger room size typically results in longer reverb time.
TypeMinMaxDefault
Number
010.8

roomSize

PROPERTY
Room size controls the scale of the decay time and reflections found in the physical characteristics of living spaces, and studios. These unique attributes will simulate the expected behavior of acoustic environments. A larger room size typically results in longer reverb time.
TypeMinMaxDefault
float
010.8

wet

PROPERTY
Loudness of the wet signal. Don't use the mix property when using the dry and wet properties.
TypeMinMaxDefault
Number
010.587

wet

PROPERTY
Loudness of the wet signal. Don't use the mix property when using the dry and wet properties.
TypeMinMaxDefault
float
010.587

width

PROPERTY
Stereo width of the reverberation.
TypeMinMaxDefault
Number
011

width

PROPERTY
Stereo width of the reverberation.
TypeMinMaxDefault
float
011
Inherited from FX Class

enabled

PROPERTY
Turns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
TypeMinMaxDefault
Boolean
false

enabled

PROPERTY
Turns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
TypeMinMaxDefault
bool
false

samplerate

PROPERTY
The sample rate of the audio context, you must update if it changes.
TypeMinMaxDefault
Number

samplerate

PROPERTY
The sample rate of the audio context, you must update if it changes.
TypeMinMaxDefault
unsigned int

Methods

  • constructor

    METHOD
    Creates a Reverb instance.
    Parameters
    NameTypeDescription
    samplerateNumberThe initial sample rate in Hz.
    maximumSamplerateNumberMaximum sample rate (affects memory usage, the lower the smaller).
    Returns
    TypeDescription
    Superpowered.ReverbThe constructed instance.
  • constructor

    METHOD
    Creates a Reverb instance.
    Parameters
    NameTypeDefaultDescription
    samplerateunsigned intThe initial sample rate in Hz.
    maximumSamplerateunsigned int96000Maximum sample rate (affects memory usage, the lower the smaller).
    Returns
    TypeDescription
    Superpowered::ReverbThe constructed instance.
Inherited from FX Class
  • destruct

    METHOD
    Destructor to free Linear Memory.
    Parameters
    None
    Returns
    None
  • process

    METHOD
    Processes/renders the audio. Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation. It's never blocking for real-time usage.
    Parameters
    NameTypeDescription
    inputNumber (pointer in Linear Memory)32-bit interleaved stereo input.
    outputNumber (pointer in Linear Memory)32-bit interleaved stereo output.
    numberOfFramesNumberNumber of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
    Returns
    TypeDescription
    BooleanIf process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, it indicates silence. The contents of output are not changed in this case (not overwritten with zeros).
  • process

    METHOD
    Processes/renders the audio. Always call it in the audio processing callback, regardless if the effect is enabled or not for smooth, audio-artifact free operation. It's never blocking for real-time usage. You can change all effect properties on any thread, concurrently with process().
    Parameters
    NameTypeDefaultDescription
    inputfloat *32-bit interleaved stereo input.
    outputfloat *32-bit interleaved stereo output.
    numberOfFramesunsigned intNumber of frames to process. Recommendations for best performance: multiply of 4, minimum 64.
    Returns
    TypeDescription
    boolIf process() returns with true, the contents of output are replaced with the audio output. If process() returns with false, it indicates silence. The contents of output are not changed in this case (not overwritten with zeros).
v2.7.2