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,
44100
);
this.reverb.enabled = true;
}
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;
}
processAudio(inputBuffer, outputBuffer, buffersize) {
this.reverb.samplerate = this.samplerate;
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) {
reverb->samplerate = samplerate;
bool outputChanged = reverb->process(interleavedInput, interleavedOutput, numberOfFrames);
...
}
Properties
damp
PROPERTYUsed 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.
Type | Min | Max | Default |
---|
Number | 0 | 1 | 0.5 |
damp
PROPERTYUsed 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.
Type | Min | Max | Default |
---|
float | 0 | 1 | 0.5 |
dry
PROPERTYLoudness of the dry signal. Don't use the mix property when using the dry and wet properties.
Type | Min | Max | Default |
---|
Number | 0 | 1 | 0.987 |
dry
PROPERTYLoudness of the dry signal. Don't use the mix property when using the dry and wet properties.
Type | Min | Max | Default |
---|
float | 0 | 1 | 0.987 |
lowCutHz
PROPERTYFrequency of the low cut in Hz (-12 db point). Controls the low frequency build up generated from the reverb.
Type | Min | Max | Default |
---|
Number | 0 | sample rate / 2 | 0 (no low frequency cut) |
lowCutHz
PROPERTYFrequency of the low cut in Hz (-12 db point). Controls the low frequency build up generated from the reverb.
Type | Min | Max | Default |
---|
float | 0 | sample rate / 2 | 0 (no low frequency cut) |
mix
PROPERTYSets dry and wet simultaneously with a nice balanced power curve. Don't use the dry and wet properties while using mix.
Type | Min | Max | Default |
---|
Number | 0 | 1 | 0.4 |
mix
PROPERTYSets dry and wet simultaneously with a nice balanced power curve. Don't use the dry and wet properties while using mix.
Type | Min | Max | Default |
---|
float | 0 | 1 | 0.4 |
predelayMs
PROPERTYPre-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.
Type | Min | Max | Default |
---|
Number | 0 | 500 | 0 |
predelayMs
PROPERTYPre-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.
Type | Min | Max | Default |
---|
float | 0 | 500 | 0 |
roomSize
PROPERTYRoom 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.
Type | Min | Max | Default |
---|
Number | 0 | 1 | 0.8 |
roomSize
PROPERTYRoom 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.
Type | Min | Max | Default |
---|
float | 0 | 1 | 0.8 |
wet
PROPERTYLoudness of the wet signal. Don't use the mix property when using the dry and wet properties.
Type | Min | Max | Default |
---|
Number | 0 | 1 | 0.587 |
wet
PROPERTYLoudness of the wet signal. Don't use the mix property when using the dry and wet properties.
Type | Min | Max | Default |
---|
float | 0 | 1 | 0.587 |
width
PROPERTYStereo width of the reverberation.
Type | Min | Max | Default |
---|
Number | 0 | 1 | 1 |
width
PROPERTYStereo width of the reverberation.
Type | Min | Max | Default |
---|
float | 0 | 1 | 1 |
Inherited from FX Classenabled
PROPERTYTurns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
Type | Min | Max | Default |
---|
Boolean | | | false |
enabled
PROPERTYTurns the effect on/off. The actual switch will happen on the next process() call for smooth, audio-artifact free operation.
Type | Min | Max | Default |
---|
bool | | | false |
samplerate
PROPERTYThe sample rate of the audio context, you must update if it changes.
samplerate
PROPERTYThe sample rate of the audio context, you must update if it changes.
Type | Min | Max | Default |
---|
unsigned int | | | |
Methods
constructor
METHODCreates a Reverb instance.
ParametersName | Type | Description |
---|
samplerate | Number | The initial sample rate in Hz. |
maximumSamplerate | Number | Maximum sample rate (affects memory usage, the lower the smaller). |
ReturnsType | Description |
---|
Superpowered.Reverb | The constructed instance. |
constructor
METHODCreates a Reverb instance.
ParametersName | Type | Default | Description |
---|
samplerate | unsigned int | | The initial sample rate in Hz. |
maximumSamplerate | unsigned int | 96000 | Maximum sample rate (affects memory usage, the lower the smaller). |
ReturnsType | Description |
---|
Superpowered::Reverb | The constructed instance. |
Inherited from FX Classdestruct
METHODDestructor to free Linear Memory.
ParametersNone
ReturnsNone
process
METHODProcesses/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.
ParametersName | Type | Description |
---|
input | Number (pointer in Linear Memory) | 32-bit interleaved stereo input. |
output | Number (pointer in Linear Memory) | 32-bit interleaved stereo output. |
numberOfFrames | Number | Number of frames to process. Recommendations for best performance: multiply of 4, minimum 64. |
ReturnsType | Description |
---|
Boolean | If 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
METHODProcesses/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().
ParametersName | Type | Default | Description |
---|
input | float * | | 32-bit interleaved stereo input. |
output | float * | | 32-bit interleaved stereo output. |
numberOfFrames | unsigned int | | Number of frames to process. Recommendations for best performance: multiply of 4, minimum 64. |
ReturnsType | Description |
---|
bool | If 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). |