Reverb
About Reverb
A reverb effect is a type of audio processing that simulates the natural reverberation of sound in a physical space. It is commonly used in music production to add depth and dimension to recordings, making them sound more natural and immersive. The most common parameters of a reverb effect include decay time, which controls how long the reverb lasts; pre-delay, which determines the time between the original sound and the onset of the reverb; and diffusion, which affects the clarity and density of the reverb. Other parameters may include room size, damping, and early reflections, which all contribute to the overall character and tone of the reverb effect. By adjusting these parameters, you can create a wide range of reverb sounds, from subtle and natural to dramatic and otherworldly.
Switchboard Editor example
This example uses the Superpowered Extension.
Why use the Superpowered Extension instead of Superpowered directly?
Code Example
- JSON
- Swift
- Kotlin
- C++
- JavaScript
{
"nodes": {
{ "id": "reverbNode", "type": "Superpowered.ReverbNode" }
},
"connections": {
{ "sourceNode": "inputNode", "destinationNode": "reverbNode" },
{ "sourceNode": "reverbNode", "destinationNode": "outputNode" }
}
}
import SwitchboardSDK
import SwitchboardSuperpowered
class ReverbExample {
let audioGraph = SBAudioGraph()
let reverbNode = SBReverbNode()
let audioEngine = SBAudioEngine()
init() {
reverbNode.isEnabled = true
audioGraph.addNode(reverbNode)
audioGraph.connect(audioGraph.inputNode, to: reverbNode)
audioGraph.connect(reverbNode, to: audioGraph.outputNode)
}
}
import com.synervoz.switchboard.sdk.audioengine.AudioEngine
import com.synervoz.switchboard.sdk.audiograph.AudioGraph
import com.synervoz.switchboardsuperpowered.audiographnodes.ReverbNode
class ReverbExample(context: Context) {
val audioEngine = AudioEngine(context)
val reverbNode = ReverbNode()
val audioGraph = AudioGraph()
init {
reverbNode.isEnabled = true
audioGraph.addNode(reverbNode)
audioGraph.connect(audioGraph.inputNode, reverbNode)
audioGraph.connect(reverbNode, audioGraph.outputNode)
audioEngine.start(audioGraph)
}
}
#include "AudioGraph.hpp"
#include "ReverbNode.hpp"
using namespace switchboard;
using namespace switchboard::extensions::superpowered;
class ReverbExample {
public:
ReverbExample() {
// Setting up node
reverbNode.setEnabled(true);
// Adding nodes to audio graph
audioGraph.addNode(reverbNode);
// Connecting audio nodes
audioGraph.connect(audioGraph.getInputNode(), reverbNode);
audioGraph.connect(reverbNode, audioGraph.getOutputNode());
// Starting the graph
audioGraph.start();
}
// Example method called by the audio processing pipeline on each buffer
bool process(float** buffers, const uint numberOfChannels, const uint numberOfFrames, const uint sampleRate) {
AudioBuffer<float> inBuffer = AudioBuffer<float>(numberOfChannels, numberOfFrames, false, sampleRate, buffers);
AudioBuffer<float> outBuffer = AudioBuffer<float>(numberOfChannels, numberOfFrames, false, sampleRate, buffers);
const bool result = audioGraph->process(&inBuffer, &outBuffer);
return result;
}
private:
AudioGraph audioGraph;
ReverbNode reverbNode;
};
// Change the import to reflect the location of library
// relative to this publically accessible AudioWorklet
import '../../../libs/superpowered/Superpowered.js'
class SuperpoweredReverbProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor {
onReady() {
this.reverb = new this.Superpowered.Reverb(
this.samplerate, // The initial sample rate in Hz.
this.samplerate // Maximum sample rate (affects memory usage, the lower the smaller).
)
this.reverb.mix = 0.04
this.reverb.enabled = true
}
onDestruct() {
this.reverb.destruct()
}
applyPreset(preset) {
for (const effectName of Object.keys(preset)) {
for (const property of Object.keys(preset[effectName])) {
this[effectName][property] = preset[effectName][property]
uiDefinitions.parameters.find((p) => p.id === property).defaultValue =
preset[effectName][property]
}
}
}
// messages are received from the main scope through this method.
onMessageFromMainScope(message) {
if (message.command === 'requestUiDefinitions') {
this.sendMessageToMainScope({ uiDefinitions: uiDefinitions })
}
if (message.command === 'applyPreset') {
this.applyPreset(message.preset)
this.sendMessageToMainScope({ updateUiDefinitions: uiDefinitions })
}
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
if (typeof message.enabled !== 'undefined')
this.reverb.enabled = message.enabled
}
processAudio(inputBuffer, outputBuffer, buffersize, parameters) {
if (
!this.reverb.process(
inputBuffer.pointer,
outputBuffer.pointer,
buffersize
)
)
this.Superpowered.memoryCopy(
outputBuffer.pointer,
inputBuffer.pointer,
buffersize * 8
)
}
}
registerProcessor('SuperpoweredReverbProcessor', SuperpoweredReverbProcessor)