FX Class: Three Band EQ
Interactive example
Overview
Classic three-band equalizer with unique characteristics and total kills. EQ or equalization affects the volume in dB of a specific frequency or a range of frequencies.
The low
, mid
, and high
properties have their respective frequency range, that is dynamically changing depending on their setting to provide the most natural frequency response for mixing.
The effect doesn’t allocate any internal buffers and needs just a few bytes of memory.
Implementation example
The three band is is an FX class, it expects both an input and output buffer. The process()
function should be called on every loop of the audio processing block.
class SuperpoweredThreeBandEqProcessor extends SuperpoweredWebAudio.AudioWorkletProcessor {// Called when the AudioWorklet is ready to start processing audioonReady() {this.eq = new this.Superpowered.ThreeBandEQ(44100 // The initial sample rate in Hz. -);this.eq.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.eq.destruct();}// The shape of the message we pass from our main thread is up to youonMessageFromMainScope(message) {// Here is an example of how to apply changes to the Three Band EQ instanceif (typeof message.low !== 'undefined') this.eq.dry = message.dry;if (typeof message.mid !== 'undefined') this.eq.wet = message.wet;if (typeof message.high !== 'undefined') this.eq.mix = message.mix;}// This is the process loop which is passed pointers to buffers// from the WebAudio API (inputBuffer and outputBuffer), with the buffersize (128 samples when running as a native AudioWorklet)processAudio(inputBuffer, outputBuffer, buffersize) {// Ensure the samplerate is in sync on every audio processing callbackthis.eq.samplerate = this.samplerate;// Render the output buffersif (!this.eq.process(inputBuffer.pointer, outputBuffer.pointer, buffersize)) {for (let n = 0; n < buffersize * 2 ; n++) outputBuffer.array[n] = inputBuffer.array[n];}}}
#include "SuperpoweredThreeBandEq.h"void initEQEffect() {const unsigned int sampleRate = 44100;eq = new Superpowered::ThreeBandEQ(sampleRate);eq->enabled = true;}void configureEQ() {eq->low = 0;eq->mid = 0.587;eq->high = 0.4;}void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames, unsigned int samplerate) {// Ensure the samplerate is in sync on every audio processing callbackeq->samplerate = samplerate;// Render the output buffersbool outputChanged = eq->process(interleavedInput, interleavedOutput, numberOfFrames);...}
Properties
high
PROPERTYHigh gain. Read-write. 1 is "flat", 2 is +6db. Kill is enabled under -40 db (0.01).
Type | Min | Max | Default | Number | 0 | 8 | 1 |
---|
high
PROPERTYHigh gain. Read-write. 1 is "flat", 2 is +6db. Kill is enabled under -40 db (0.01).
Type | Min | Max | Default | float | 0 | 8 | 1 |
---|
low
PROPERTYLow gain. Read-write. 1 is "flat", 2 is +6db. Kill is enabled under -40 db (0.01).
Type | Min | Max | Default | Number | 0 | 8 | 1 |
---|
low
PROPERTYLow gain. Read-write. 1 is "flat", 2 is +6db. Kill is enabled under -40 db (0.01).
Type | Min | Max | Default | float | 0 | 8 | 1 |
---|
mid
PROPERTYMid gain. Read-write. 1 is "flat", 2 is +6db. Kill is enabled under -40 db (0.01).
Type | Min | Max | Default | Number | 0 | 8 | 1 |
---|
mid
PROPERTYMid gain. Read-write. 1 is "flat", 2 is +6db. Kill is enabled under -40 db (0.01).
Type | Min | Max | Default | float | 0 | 8 | 1 |
---|
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 | 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.
Type | Min | Max | Default | Number |
---|
samplerate
PROPERTYThe sample rate of the audio context, you must update if it changes.
Type | Min | Max | Default | unsigned int |
---|
Methods
constructor
METHODCreates a ThreeBandEQ instance.ParametersReturnsName Type Description samplerate Number
The initial sample rate in Hz. Type Description Superpowered.ThreeBandEQ
The constructed instance. constructor
METHODCreates a ThreeBandEQ instance.ParametersReturnsName Type Default Description samplerate unsigned int
The initial sample rate in Hz. Type Description Superpowered::ThreeBandEQ
The constructed instance.
destruct
METHODDestructor to free Linear Memory.ParametersNoneReturnsNoneprocess
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.ParametersReturnsName 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. Type 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().ParametersReturnsName 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. Type 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).