SaturationAnalog-style saturation, processed in WebAssembly with first-order antiderivative anti-aliasing (ADAA). ADAA strongly reduces the harsh, inharmonic aliasing of plain waveshaping, at a fraction of the cost of oversampling.
Extends Effector.
| Mode | Curve | Character |
|---|---|---|
| "soft" | tanh(x) | Smooth and symmetric. Odd harmonics. |
| "tube" | tanh(x + bias) - tanh(bias) | Asymmetric. Adds even harmonics, sounds warmer. A DC blocker removes the offset. |
| "tape" | x / (1 + abs(x)) | Gentle knee. Compresses gradually. |
input -+-> drive -> curve (ADAA) -> DC blocker -> tone (lowpass) -> 1/sqrt(drive) -> output gain -+-> mix -> output
+----------------------------------------- dry --------------------------------------------+
The saturated signal is scaled by 1 / sqrt(drive). That keeps level changes moderate when you raise the drive: quiet signals get somewhat louder, loud signals somewhat quieter. Use outputGain to match the level.
import { Saturation } from "@fluex/fluexgl-dsp";
const warmth = new Saturation({ mode: "tube", drive: 12, tone: 8000, mix: 0.5 });
channel.addEffect(warmth);
warmth.setDrive(18);
new Saturation(options?: Partial<SaturationOptions>): Saturation;
options?: Partial<SaturationOptions>
Every field is optional, falls back to the defaults below, and is clamped to its valid range.| Property | Range | Default |
|---|---|---|
| drive: number | 0 to 48 dB | 12 |
| mode: SaturationMode | "soft", "tube", "tape" | "soft" |
| tone: number | 0 (off) or a lowpass frequency in Hz (from 200 Hz) | 0 |
| mix: number | 0 to 1 | 1 |
| outputGain: number | -24 to 24 dB | 0 |
| strictMode: StrictMode | | StrictMode.Disabled |
label and name default to "Saturation".
initializeOnAttachment(context: AudioContext): Promise<void>Creates the SaturationProcessor AudioWorklet node with the current values.
returnOptionsAsObject(): SaturationOptionsReturns a snapshot of the current values.
setDrive(drive: number): booleanSets the drive (dB), clamped between 0 and 48.
drive: numberboolean - true when the value was sent to the processor (or applied to the audio node), false when the effect is not attached yet. The value is stored either way and used on attachment.setMode(mode: SaturationMode): booleanSwitches the curve. Returns false for an unknown mode.
mode: "soft" | "tube" | "tape"boolean - true when the value was sent to the processor (or applied to the audio node), false when the effect is not attached yet. The value is stored either way and used on attachment.setTone(tone: number): booleanSets the lowpass after the curve (Hz). 0 disables it.
tone: numberboolean - true when the value was sent to the processor (or applied to the audio node), false when the effect is not attached yet. The value is stored either way and used on attachment.setMix(mix: number): booleanSets the dry/wet mix, clamped between 0 and 1.
mix: numberboolean - true when the value was sent to the processor (or applied to the audio node), false when the effect is not attached yet. The value is stored either way and used on attachment.setOutputGain(outputGain: number): booleanSets the gain of the saturated signal (dB), clamped between -24 and 24.
outputGain: numberboolean - true when the value was sent to the processor (or applied to the audio node), false when the effect is not attached yet. The value is stored either way and used on attachment.Inherited from Effector. The SaturationProcessor processor sends processor-wasm-instantiated when its WebAssembly module is ready, and an incoming-processor-message for every parameter change.
Runs on an AudioWorklet backed by WebAssembly. Attach it only after await pipeline.initializeDpsPipeline(), on the AudioDevice returned by resolveDefaultAudioOutputDevice(). Requires a worklet and WASM build from FluexGL-DSP-WebAssembly 0.4.9 or newer, which registers SaturationProcessor.