@codexo/exojs-audio-fx 0.15.3 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/AudioAnalyser.d.ts +4 -3
- package/dist/esm/AudioAnalyser.d.ts.map +1 -0
- package/dist/esm/AudioAnalyser.js +365 -468
- package/dist/esm/AudioAnalyser.js.map +1 -1
- package/dist/esm/BeatDetector.d.ts +16 -15
- package/dist/esm/BeatDetector.d.ts.map +1 -0
- package/dist/esm/BeatDetector.js +370 -428
- package/dist/esm/BeatDetector.js.map +1 -1
- package/dist/esm/dsp/fft.d.ts +5 -5
- package/dist/esm/dsp/fft.d.ts.map +1 -0
- package/dist/esm/dsp/mel.d.ts +6 -6
- package/dist/esm/dsp/mel.d.ts.map +1 -0
- package/dist/esm/dsp/mel.js +55 -64
- package/dist/esm/dsp/mel.js.map +1 -1
- package/dist/esm/dsp/tempogram.d.ts +60 -20
- package/dist/esm/dsp/tempogram.d.ts.map +1 -0
- package/dist/esm/effects/AutoWahEffect.d.ts +3 -2
- package/dist/esm/effects/AutoWahEffect.d.ts.map +1 -0
- package/dist/esm/effects/AutoWahEffect.js +210 -237
- package/dist/esm/effects/AutoWahEffect.js.map +1 -1
- package/dist/esm/effects/BitCrusherEffect.d.ts +3 -2
- package/dist/esm/effects/BitCrusherEffect.d.ts.map +1 -0
- package/dist/esm/effects/BitCrusherEffect.js +72 -70
- package/dist/esm/effects/BitCrusherEffect.js.map +1 -1
- package/dist/esm/effects/ChorusEffect.d.ts +2 -1
- package/dist/esm/effects/ChorusEffect.d.ts.map +1 -0
- package/dist/esm/effects/ChorusEffect.js +132 -150
- package/dist/esm/effects/ChorusEffect.js.map +1 -1
- package/dist/esm/effects/CompressorEffect.d.ts +2 -1
- package/dist/esm/effects/CompressorEffect.d.ts.map +1 -0
- package/dist/esm/effects/CompressorEffect.js +104 -118
- package/dist/esm/effects/CompressorEffect.js.map +1 -1
- package/dist/esm/effects/ConvolutionEffect.d.ts +10 -5
- package/dist/esm/effects/ConvolutionEffect.d.ts.map +1 -0
- package/dist/esm/effects/ConvolutionEffect.js +208 -189
- package/dist/esm/effects/ConvolutionEffect.js.map +1 -1
- package/dist/esm/effects/DelayEffect.d.ts +1 -0
- package/dist/esm/effects/DelayEffect.d.ts.map +1 -0
- package/dist/esm/effects/DelayEffect.js +105 -109
- package/dist/esm/effects/DelayEffect.js.map +1 -1
- package/dist/esm/effects/DistortionEffect.d.ts +4 -3
- package/dist/esm/effects/DistortionEffect.d.ts.map +1 -0
- package/dist/esm/effects/DistortionEffect.js +190 -195
- package/dist/esm/effects/DistortionEffect.js.map +1 -1
- package/dist/esm/effects/DuckingEffect.d.ts +3 -2
- package/dist/esm/effects/DuckingEffect.d.ts.map +1 -0
- package/dist/esm/effects/DuckingEffect.js +91 -172
- package/dist/esm/effects/DuckingEffect.js.map +1 -1
- package/dist/esm/effects/EqualizerEffect.d.ts +1 -0
- package/dist/esm/effects/EqualizerEffect.d.ts.map +1 -0
- package/dist/esm/effects/EqualizerEffect.js +120 -133
- package/dist/esm/effects/EqualizerEffect.js.map +1 -1
- package/dist/esm/effects/FlangerEffect.d.ts +7 -6
- package/dist/esm/effects/FlangerEffect.d.ts.map +1 -0
- package/dist/esm/effects/FlangerEffect.js +172 -201
- package/dist/esm/effects/FlangerEffect.js.map +1 -1
- package/dist/esm/effects/GranularEffect.d.ts +3 -2
- package/dist/esm/effects/GranularEffect.d.ts.map +1 -0
- package/dist/esm/effects/GranularEffect.js +100 -95
- package/dist/esm/effects/GranularEffect.js.map +1 -1
- package/dist/esm/effects/LimiterEffect.d.ts +1 -0
- package/dist/esm/effects/LimiterEffect.d.ts.map +1 -0
- package/dist/esm/effects/LimiterEffect.js +182 -194
- package/dist/esm/effects/LimiterEffect.js.map +1 -1
- package/dist/esm/effects/PhaserEffect.d.ts +2 -1
- package/dist/esm/effects/PhaserEffect.d.ts.map +1 -0
- package/dist/esm/effects/PhaserEffect.js +214 -254
- package/dist/esm/effects/PhaserEffect.js.map +1 -1
- package/dist/esm/effects/PingPongDelayEffect.d.ts +2 -1
- package/dist/esm/effects/PingPongDelayEffect.d.ts.map +1 -0
- package/dist/esm/effects/PingPongDelayEffect.js +172 -185
- package/dist/esm/effects/PingPongDelayEffect.js.map +1 -1
- package/dist/esm/effects/PitchShiftEffect.d.ts +3 -2
- package/dist/esm/effects/PitchShiftEffect.d.ts.map +1 -0
- package/dist/esm/effects/PitchShiftEffect.js +60 -60
- package/dist/esm/effects/PitchShiftEffect.js.map +1 -1
- package/dist/esm/effects/ReverbEffect.d.ts +2 -1
- package/dist/esm/effects/ReverbEffect.d.ts.map +1 -0
- package/dist/esm/effects/ReverbEffect.js +113 -117
- package/dist/esm/effects/ReverbEffect.js.map +1 -1
- package/dist/esm/effects/RingModulatorEffect.d.ts +4 -3
- package/dist/esm/effects/RingModulatorEffect.d.ts.map +1 -0
- package/dist/esm/effects/RingModulatorEffect.js +153 -161
- package/dist/esm/effects/RingModulatorEffect.js.map +1 -1
- package/dist/esm/effects/TremoloEffect.d.ts +1 -0
- package/dist/esm/effects/TremoloEffect.d.ts.map +1 -0
- package/dist/esm/effects/TremoloEffect.js +193 -201
- package/dist/esm/effects/TremoloEffect.js.map +1 -1
- package/dist/esm/effects/VocoderEffect.d.ts +2 -1
- package/dist/esm/effects/VocoderEffect.d.ts.map +1 -0
- package/dist/esm/effects/VocoderEffect.js +69 -80
- package/dist/esm/effects/VocoderEffect.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +23 -22
- package/dist/esm/worklets/beat-detector.worklet.js +5 -1162
- package/dist/esm/worklets/beat-detector.worklet.js.map +1 -1
- package/dist/esm/worklets/bit-crusher.worklet.js +5 -44
- package/dist/esm/worklets/bit-crusher.worklet.js.map +1 -1
- package/dist/esm/worklets/ducking.worklet.js +6 -0
- package/dist/esm/worklets/ducking.worklet.js.map +1 -0
- package/dist/esm/worklets/granular.worklet.js +5 -97
- package/dist/esm/worklets/granular.worklet.js.map +1 -1
- package/dist/esm/worklets/pitch-shift.worklet.js +5 -128
- package/dist/esm/worklets/pitch-shift.worklet.js.map +1 -1
- package/dist/esm/worklets/vocoder.worklet.js +5 -93
- package/dist/esm/worklets/vocoder.worklet.js.map +1 -1
- package/package.json +6 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/worklets/beat-detector.worklet.d.ts +0 -1
- package/dist/esm/worklets/bit-crusher.worklet.d.ts +0 -1
- package/dist/esm/worklets/granular.worklet.d.ts +0 -1
- package/dist/esm/worklets/pitch-shift.worklet.d.ts +0 -1
- package/dist/esm/worklets/vocoder.worklet.d.ts +0 -1
|
@@ -1,199 +1,194 @@
|
|
|
1
|
-
import { AudioEffect,
|
|
1
|
+
import { AudioEffect, getAudioContext, isAudioContextReady, onAudioContextReady } from "@codexo/exojs";
|
|
2
2
|
|
|
3
|
+
//#region src/effects/DistortionEffect.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class DistortionEffect extends AudioEffect {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
inputGain.connect(waveShaper);
|
|
191
|
-
waveShaper.connect(toneFilter);
|
|
192
|
-
toneFilter.connect(wetGain);
|
|
193
|
-
wetGain.connect(outputGain);
|
|
194
|
-
this._setup = { inputGain, outputGain, dryGain, wetGain, waveShaper, toneFilter };
|
|
195
|
-
}
|
|
196
|
-
}
|
|
5
|
+
* Distortion effect built from native Web Audio nodes - no worklet required.
|
|
6
|
+
*
|
|
7
|
+
* The input signal is split into a dry path and a wet path. The wet path runs
|
|
8
|
+
* through a `WaveShaperNode` loaded with a tanh-based soft-clip curve, then
|
|
9
|
+
* through a `BiquadFilterNode` (lowpass) acting as a tone control, before
|
|
10
|
+
* being mixed back with the dry signal. The wave-shaper curve is rebuilt any
|
|
11
|
+
* time `drive` changes. Oversampling is delegated directly to
|
|
12
|
+
* `WaveShaperNode.oversample`.
|
|
13
|
+
*
|
|
14
|
+
* Node graph:
|
|
15
|
+
* ```
|
|
16
|
+
* input(GainNode) ──── dryGain ─────────────────────────── output(GainNode)
|
|
17
|
+
* input ──── waveShaper ── toneFilter ── wetGain ── output
|
|
18
|
+
* ```
|
|
19
|
+
* Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const dist = new DistortionEffect({ drive: 0.7, wet: 0.9, tone: 0.6 });
|
|
24
|
+
* bus.addEffect(dist);
|
|
25
|
+
*
|
|
26
|
+
* // Soften the drive at runtime:
|
|
27
|
+
* dist.drive = 0.3;
|
|
28
|
+
*
|
|
29
|
+
* // Open the tone filter fully:
|
|
30
|
+
* dist.tone = 1;
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
var DistortionEffect = class DistortionEffect extends AudioEffect {
|
|
34
|
+
_setup = null;
|
|
35
|
+
_drive;
|
|
36
|
+
_wet;
|
|
37
|
+
_oversample;
|
|
38
|
+
_tone;
|
|
39
|
+
_onAudioContextReady = (ctx) => {
|
|
40
|
+
onAudioContextReady.remove(this._onAudioContextReady);
|
|
41
|
+
this._setupNodes(ctx);
|
|
42
|
+
};
|
|
43
|
+
constructor(options = {}) {
|
|
44
|
+
super();
|
|
45
|
+
this._drive = Math.max(0, Math.min(1, options.drive ?? .4));
|
|
46
|
+
this._wet = Math.max(0, Math.min(1, options.wet ?? 1));
|
|
47
|
+
this._oversample = options.oversample ?? "2x";
|
|
48
|
+
this._tone = Math.max(0, Math.min(1, options.tone ?? 1));
|
|
49
|
+
if (isAudioContextReady()) this._setupNodes(getAudioContext());
|
|
50
|
+
else onAudioContextReady.add(this._onAudioContextReady);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The node where audio enters this effect. Throws if the audio context is
|
|
54
|
+
* not yet initialized.
|
|
55
|
+
*/
|
|
56
|
+
get inputNode() {
|
|
57
|
+
if (!this._setup) throw new Error("DistortionEffect not yet initialized.");
|
|
58
|
+
return this._setup.inputGain;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The node where audio exits this effect. Throws if the audio context is
|
|
62
|
+
* not yet initialized.
|
|
63
|
+
*/
|
|
64
|
+
get outputNode() {
|
|
65
|
+
if (!this._setup) throw new Error("DistortionEffect not yet initialized.");
|
|
66
|
+
return this._setup.outputGain;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Drive amount controlling the soft-clip intensity. Range 0..1, default 0.4.
|
|
70
|
+
* Changing this rebuilds the wave-shaper curve immediately (sample-accurate
|
|
71
|
+
* on the next render quantum).
|
|
72
|
+
*/
|
|
73
|
+
get drive() {
|
|
74
|
+
return this._drive;
|
|
75
|
+
}
|
|
76
|
+
set drive(value) {
|
|
77
|
+
this._drive = Math.max(0, Math.min(1, value));
|
|
78
|
+
if (this._setup) this._setup.waveShaper.curve = DistortionEffect._buildCurve(this._drive);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Wet (distorted) mix level, 0..1. The dry level is automatically `1 - wet`.
|
|
82
|
+
* Changes are ramped smoothly via `setTargetAtTime`. Default 1.0.
|
|
83
|
+
*/
|
|
84
|
+
get wet() {
|
|
85
|
+
return this._wet;
|
|
86
|
+
}
|
|
87
|
+
set wet(value) {
|
|
88
|
+
this._wet = Math.max(0, Math.min(1, value));
|
|
89
|
+
if (this._setup) {
|
|
90
|
+
const ctx = this._setup.wetGain.context;
|
|
91
|
+
this._setup.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, .01);
|
|
92
|
+
this._setup.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, .01);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Oversampling mode for the `WaveShaperNode`. One of `'none'`, `'2x'`, or
|
|
97
|
+
* `'4x'`. Higher values reduce aliasing but increase CPU usage. Default `'2x'`.
|
|
98
|
+
*/
|
|
99
|
+
get oversample() {
|
|
100
|
+
return this._oversample;
|
|
101
|
+
}
|
|
102
|
+
set oversample(value) {
|
|
103
|
+
this._oversample = value;
|
|
104
|
+
if (this._setup) this._setup.waveShaper.oversample = this._oversample;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Tone control: low-pass cutoff on the wet path. 0 = fully dark (~100 Hz),
|
|
108
|
+
* 1 = fully open (~20 kHz). Mapped logarithmically. Default 1.
|
|
109
|
+
* Changes are ramped smoothly via `setTargetAtTime`.
|
|
110
|
+
*/
|
|
111
|
+
get tone() {
|
|
112
|
+
return this._tone;
|
|
113
|
+
}
|
|
114
|
+
set tone(value) {
|
|
115
|
+
this._tone = Math.max(0, Math.min(1, value));
|
|
116
|
+
if (this._setup) {
|
|
117
|
+
const ctx = this._setup.toneFilter.context;
|
|
118
|
+
this._setup.toneFilter.frequency.setTargetAtTime(DistortionEffect._toneToFrequency(this._tone), ctx.currentTime, .01);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
destroy() {
|
|
122
|
+
onAudioContextReady.remove(this._onAudioContextReady);
|
|
123
|
+
if (this._setup) {
|
|
124
|
+
this._setup.inputGain.disconnect();
|
|
125
|
+
this._setup.waveShaper.disconnect();
|
|
126
|
+
this._setup.toneFilter.disconnect();
|
|
127
|
+
this._setup.dryGain.disconnect();
|
|
128
|
+
this._setup.wetGain.disconnect();
|
|
129
|
+
this._setup.outputGain.disconnect();
|
|
130
|
+
this._setup = null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Build a 256-point tanh-based soft-clip curve for the given drive (0..1).
|
|
135
|
+
*
|
|
136
|
+
* Maps drive to a distortion amount `a = drive * 400 + 1`, then fills the
|
|
137
|
+
* curve with `tanh(x * a) / tanh(a)` so that the output is always bounded
|
|
138
|
+
* to [-1, 1]. At drive=0, `a = 1` and the curve is `tanh(x) / tanh(1)`,
|
|
139
|
+
* which has a small-signal gain of `1/tanh(1) ≈ 1.31` - not perfectly
|
|
140
|
+
* linear. At drive=1, `a = 401` and the curve approximates a hard-clipper.
|
|
141
|
+
*/
|
|
142
|
+
static _buildCurve(drive) {
|
|
143
|
+
const n = 256;
|
|
144
|
+
const curve = new Float32Array(n);
|
|
145
|
+
const amount = drive * 400 + 1;
|
|
146
|
+
const norm = Math.tanh(amount);
|
|
147
|
+
for (let i = 0; i < n; i++) {
|
|
148
|
+
const x = i * 2 / 255 - 1;
|
|
149
|
+
curve[i] = Math.tanh(x * amount) / norm;
|
|
150
|
+
}
|
|
151
|
+
return curve;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Map tone (0..1) to a low-pass cutoff frequency in Hz.
|
|
155
|
+
* Logarithmic scale: 100 Hz at tone=0, 20 000 Hz at tone=1.
|
|
156
|
+
*/
|
|
157
|
+
static _toneToFrequency(tone) {
|
|
158
|
+
return 100 * Math.pow(200, tone);
|
|
159
|
+
}
|
|
160
|
+
_setupNodes(ctx) {
|
|
161
|
+
const inputGain = ctx.createGain();
|
|
162
|
+
const outputGain = ctx.createGain();
|
|
163
|
+
const dryGain = ctx.createGain();
|
|
164
|
+
const wetGain = ctx.createGain();
|
|
165
|
+
const waveShaper = ctx.createWaveShaper();
|
|
166
|
+
const toneFilter = ctx.createBiquadFilter();
|
|
167
|
+
inputGain.gain.setValueAtTime(1, ctx.currentTime);
|
|
168
|
+
outputGain.gain.setValueAtTime(1, ctx.currentTime);
|
|
169
|
+
dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);
|
|
170
|
+
wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);
|
|
171
|
+
waveShaper.curve = DistortionEffect._buildCurve(this._drive);
|
|
172
|
+
waveShaper.oversample = this._oversample;
|
|
173
|
+
toneFilter.type = "lowpass";
|
|
174
|
+
toneFilter.frequency.setValueAtTime(DistortionEffect._toneToFrequency(this._tone), ctx.currentTime);
|
|
175
|
+
inputGain.connect(dryGain);
|
|
176
|
+
dryGain.connect(outputGain);
|
|
177
|
+
inputGain.connect(waveShaper);
|
|
178
|
+
waveShaper.connect(toneFilter);
|
|
179
|
+
toneFilter.connect(wetGain);
|
|
180
|
+
wetGain.connect(outputGain);
|
|
181
|
+
this._setup = {
|
|
182
|
+
inputGain,
|
|
183
|
+
outputGain,
|
|
184
|
+
dryGain,
|
|
185
|
+
wetGain,
|
|
186
|
+
waveShaper,
|
|
187
|
+
toneFilter
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
197
191
|
|
|
192
|
+
//#endregion
|
|
198
193
|
export { DistortionEffect };
|
|
199
|
-
//# sourceMappingURL=DistortionEffect.js.map
|
|
194
|
+
//# sourceMappingURL=DistortionEffect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DistortionEffect.js","sources":["../../../../src/effects/DistortionEffect.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,MAAO,gBAAiB,SAAQ,WAAW,CAAA;IACvC,MAAM,GAAiC,IAAI;AAC3C,IAAA,MAAM;AACN,IAAA,IAAI;AACJ,IAAA,WAAW;AACX,IAAA,KAAK;AACI,IAAA,oBAAoB,GAAG,CAAC,GAAiB,KAAU;AAClE,QAAA,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;AACrD,QAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;AACvB,IAAA,CAAC;AAED,IAAA,WAAA,CAAmB,UAAmC,EAAE,EAAA;AACtD,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;QACxD,IAAI,mBAAmB,EAAE,EAAE;AACzB,YAAA,IAAI,CA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AO,CAAC,UAAU,CAAC;AAE3B,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE;IACnF;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"DistortionEffect.js","names":[],"sources":["../../../src/effects/DistortionEffect.ts"],"sourcesContent":["import { AudioEffect, getAudioContext, isAudioContextReady, onAudioContextReady } from '@codexo/exojs';\n\n/** Construction options for {@link DistortionEffect}. */\nexport interface DistortionEffectOptions {\n /**\n * Drive amount: controls the intensity of the tanh soft-clip curve.\n * Range 0..1, default 0.4. Higher values produce heavier, more saturated\n * distortion; lower values produce a milder soft-clip. Note that even at\n * drive=0 the curve is not perfectly linear - the formula\n * `tanh(x) / tanh(1)` has a gain of `1/tanh(1) ≈ 1.31` at the origin.\n */\n drive?: number;\n /**\n * Dry/wet mix, 0..1. The dry level is automatically `1 - wet`. Default 1.0.\n */\n wet?: number;\n /**\n * Oversampling mode applied by the `WaveShaperNode`. Higher oversampling\n * reduces aliasing artifacts at the cost of extra CPU. One of `'none'`,\n * `'2x'`, or `'4x'`. Default `'2x'`.\n */\n oversample?: OverSampleType;\n /**\n * Tone control: cutoff of a post-distortion low-pass filter on the wet path.\n * Mapped logarithmically from 100 Hz (tone=0, fully dark) to 20 kHz\n * (tone=1, fully open). Range 0..1, default 1.\n */\n tone?: number;\n}\n\ninterface DistortionEffectSetup {\n readonly inputGain: GainNode;\n readonly outputGain: GainNode;\n readonly dryGain: GainNode;\n readonly wetGain: GainNode;\n readonly waveShaper: WaveShaperNode;\n readonly toneFilter: BiquadFilterNode;\n}\n\n/**\n * Distortion effect built from native Web Audio nodes - no worklet required.\n *\n * The input signal is split into a dry path and a wet path. The wet path runs\n * through a `WaveShaperNode` loaded with a tanh-based soft-clip curve, then\n * through a `BiquadFilterNode` (lowpass) acting as a tone control, before\n * being mixed back with the dry signal. The wave-shaper curve is rebuilt any\n * time `drive` changes. Oversampling is delegated directly to\n * `WaveShaperNode.oversample`.\n *\n * Node graph:\n * ```\n * input(GainNode) ──── dryGain ─────────────────────────── output(GainNode)\n * input ──── waveShaper ── toneFilter ── wetGain ── output\n * ```\n * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`.\n *\n * @example\n * ```ts\n * const dist = new DistortionEffect({ drive: 0.7, wet: 0.9, tone: 0.6 });\n * bus.addEffect(dist);\n *\n * // Soften the drive at runtime:\n * dist.drive = 0.3;\n *\n * // Open the tone filter fully:\n * dist.tone = 1;\n * ```\n */\nexport class DistortionEffect extends AudioEffect {\n private _setup: DistortionEffectSetup | null = null;\n private _drive: number;\n private _wet: number;\n private _oversample: OverSampleType;\n private _tone: number;\n private readonly _onAudioContextReady = (ctx: AudioContext): void => {\n onAudioContextReady.remove(this._onAudioContextReady);\n this._setupNodes(ctx);\n };\n\n public constructor(options: DistortionEffectOptions = {}) {\n super();\n this._drive = Math.max(0, Math.min(1, options.drive ?? 0.4));\n this._wet = Math.max(0, Math.min(1, options.wet ?? 1));\n this._oversample = options.oversample ?? '2x';\n this._tone = Math.max(0, Math.min(1, options.tone ?? 1));\n if (isAudioContextReady()) {\n this._setupNodes(getAudioContext());\n } else {\n onAudioContextReady.add(this._onAudioContextReady);\n }\n }\n\n /**\n * The node where audio enters this effect. Throws if the audio context is\n * not yet initialized.\n */\n public get inputNode(): AudioNode {\n if (!this._setup) throw new Error('DistortionEffect not yet initialized.');\n return this._setup.inputGain;\n }\n\n /**\n * The node where audio exits this effect. Throws if the audio context is\n * not yet initialized.\n */\n public get outputNode(): AudioNode {\n if (!this._setup) throw new Error('DistortionEffect not yet initialized.');\n return this._setup.outputGain;\n }\n\n /**\n * Drive amount controlling the soft-clip intensity. Range 0..1, default 0.4.\n * Changing this rebuilds the wave-shaper curve immediately (sample-accurate\n * on the next render quantum).\n */\n public get drive(): number {\n return this._drive;\n }\n\n public set drive(value: number) {\n this._drive = Math.max(0, Math.min(1, value));\n if (this._setup) {\n this._setup.waveShaper.curve = DistortionEffect._buildCurve(this._drive);\n }\n }\n\n /**\n * Wet (distorted) mix level, 0..1. The dry level is automatically `1 - wet`.\n * Changes are ramped smoothly via `setTargetAtTime`. Default 1.0.\n */\n public get wet(): number {\n return this._wet;\n }\n\n public set wet(value: number) {\n this._wet = Math.max(0, Math.min(1, value));\n if (this._setup) {\n const ctx = this._setup.wetGain.context;\n this._setup.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, 0.01);\n this._setup.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, 0.01);\n }\n }\n\n /**\n * Oversampling mode for the `WaveShaperNode`. One of `'none'`, `'2x'`, or\n * `'4x'`. Higher values reduce aliasing but increase CPU usage. Default `'2x'`.\n */\n public get oversample(): OverSampleType {\n return this._oversample;\n }\n\n public set oversample(value: OverSampleType) {\n this._oversample = value;\n if (this._setup) {\n this._setup.waveShaper.oversample = this._oversample;\n }\n }\n\n /**\n * Tone control: low-pass cutoff on the wet path. 0 = fully dark (~100 Hz),\n * 1 = fully open (~20 kHz). Mapped logarithmically. Default 1.\n * Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get tone(): number {\n return this._tone;\n }\n\n public set tone(value: number) {\n this._tone = Math.max(0, Math.min(1, value));\n if (this._setup) {\n const ctx = this._setup.toneFilter.context;\n this._setup.toneFilter.frequency.setTargetAtTime(DistortionEffect._toneToFrequency(this._tone), ctx.currentTime, 0.01);\n }\n }\n\n public override destroy(): void {\n onAudioContextReady.remove(this._onAudioContextReady);\n if (this._setup) {\n this._setup.inputGain.disconnect();\n this._setup.waveShaper.disconnect();\n this._setup.toneFilter.disconnect();\n this._setup.dryGain.disconnect();\n this._setup.wetGain.disconnect();\n this._setup.outputGain.disconnect();\n this._setup = null;\n }\n }\n\n /**\n * Build a 256-point tanh-based soft-clip curve for the given drive (0..1).\n *\n * Maps drive to a distortion amount `a = drive * 400 + 1`, then fills the\n * curve with `tanh(x * a) / tanh(a)` so that the output is always bounded\n * to [-1, 1]. At drive=0, `a = 1` and the curve is `tanh(x) / tanh(1)`,\n * which has a small-signal gain of `1/tanh(1) ≈ 1.31` - not perfectly\n * linear. At drive=1, `a = 401` and the curve approximates a hard-clipper.\n */\n private static _buildCurve(drive: number): Float32Array<ArrayBuffer> {\n const n = 256;\n const curve: Float32Array<ArrayBuffer> = new Float32Array(n);\n // drive=0 → amount=1 (mild curve: gain ≈ 1/tanh(1) ≈ 1.31 at origin); drive=1 → amount=401 (near hard-clip)\n const amount = drive * 400 + 1;\n const norm = Math.tanh(amount);\n for (let i = 0; i < n; i++) {\n const x = (i * 2) / (n - 1) - 1;\n curve[i] = Math.tanh(x * amount) / norm;\n }\n return curve;\n }\n\n /**\n * Map tone (0..1) to a low-pass cutoff frequency in Hz.\n * Logarithmic scale: 100 Hz at tone=0, 20 000 Hz at tone=1.\n */\n private static _toneToFrequency(tone: number): number {\n // 100 * 200^tone: 100 Hz at 0, 20 000 Hz at 1\n return 100 * Math.pow(200, tone);\n }\n\n private _setupNodes(ctx: AudioContext): void {\n const inputGain = ctx.createGain();\n const outputGain = ctx.createGain();\n const dryGain = ctx.createGain();\n const wetGain = ctx.createGain();\n const waveShaper = ctx.createWaveShaper();\n const toneFilter = ctx.createBiquadFilter();\n\n inputGain.gain.setValueAtTime(1, ctx.currentTime);\n outputGain.gain.setValueAtTime(1, ctx.currentTime);\n dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);\n wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);\n\n waveShaper.curve = DistortionEffect._buildCurve(this._drive);\n waveShaper.oversample = this._oversample;\n\n toneFilter.type = 'lowpass';\n toneFilter.frequency.setValueAtTime(DistortionEffect._toneToFrequency(this._tone), ctx.currentTime);\n\n // Dry path: input → dryGain → output\n inputGain.connect(dryGain);\n dryGain.connect(outputGain);\n\n // Wet path: input → waveShaper → toneFilter → wetGain → output\n inputGain.connect(waveShaper);\n waveShaper.connect(toneFilter);\n toneFilter.connect(wetGain);\n wetGain.connect(outputGain);\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GAAG,IAAI,GAAG,KAAK;GAC1B,MAAM,IAAK,IAAI,IAAM,MAAS;GAC9B,MAAM,KAAK,KAAK,KAAK,IAAI,MAAM,IAAI;EACrC;EACA,OAAO;CACT;;;;;CAMA,OAAe,iBAAiB,MAAsB;EAEpD,OAAO,MAAM,KAAK,IAAI,KAAK,IAAI;CACjC;CAEA,AAAQ,YAAY,KAAyB;EAC3C,MAAM,YAAY,IAAI,WAAW;EACjC,MAAM,aAAa,IAAI,WAAW;EAClC,MAAM,UAAU,IAAI,WAAW;EAC/B,MAAM,UAAU,IAAI,WAAW;EAC/B,MAAM,aAAa,IAAI,iBAAiB;EACxC,MAAM,aAAa,IAAI,mBAAmB;EAE1C,UAAU,KAAK,eAAe,GAAG,IAAI,WAAW;EAChD,WAAW,KAAK,eAAe,GAAG,IAAI,WAAW;EACjD,QAAQ,KAAK,eAAe,IAAI,KAAK,MAAM,IAAI,WAAW;EAC1D,QAAQ,KAAK,eAAe,KAAK,MAAM,IAAI,WAAW;EAEtD,WAAW,QAAQ,iBAAiB,YAAY,KAAK,MAAM;EAC3D,WAAW,aAAa,KAAK;EAE7B,WAAW,OAAO;EAClB,WAAW,UAAU,eAAe,iBAAiB,iBAAiB,KAAK,KAAK,GAAG,IAAI,WAAW;EAGlG,UAAU,QAAQ,OAAO;EACzB,QAAQ,QAAQ,UAAU;EAG1B,UAAU,QAAQ,UAAU;EAC5B,WAAW,QAAQ,UAAU;EAC7B,WAAW,QAAQ,OAAO;EAC1B,QAAQ,QAAQ,UAAU;EAE1B,KAAK,SAAS;GAAE;GAAW;GAAY;GAAS;GAAS;GAAY;EAAW;CAClF;AACF"}
|
|
@@ -34,10 +34,11 @@ export declare class DuckingEffect extends WorkletEffect {
|
|
|
34
34
|
/** Compression ratio applied to the main signal above the threshold. Range 1..20, default 4. */
|
|
35
35
|
get ratio(): number;
|
|
36
36
|
set ratio(value: number);
|
|
37
|
-
/** Attack time in milliseconds
|
|
37
|
+
/** Attack time in milliseconds - how quickly the ducker engages. Default 30. */
|
|
38
38
|
get attackMs(): number;
|
|
39
39
|
set attackMs(value: number);
|
|
40
|
-
/** Release time in milliseconds
|
|
40
|
+
/** Release time in milliseconds - how quickly the ducker disengages. Default 300. */
|
|
41
41
|
get releaseMs(): number;
|
|
42
42
|
set releaseMs(value: number);
|
|
43
43
|
}
|
|
44
|
+
//# sourceMappingURL=DuckingEffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuckingEffect.d.ts","sourceRoot":"","sources":["../../../src/effects/DuckingEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI7D,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAG9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;gBAER,OAAO,EAAE,oBAAoB;IAYhD,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;IAED,SAAS,KAAK,cAAc,IAAI,MAAM,CAErC;IAED,cAAuB,eAAe,IAAI,uBAAuB,CAEhE;cAEkB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAyBpE,oFAAoF;IACpF,OAAO,CAAC,UAAU;IAKlB,sGAAsG;IACtG,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,IAAW,SAAS,CAAC,KAAK,EAAE,MAAM,EAGjC;IAED,gGAAgG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