@codexo/exojs-audio-fx 0.14.0 → 0.15.0

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.
Files changed (64) hide show
  1. package/dist/esm/BeatDetector.d.ts +55 -9
  2. package/dist/esm/BeatDetector.js +19 -9
  3. package/dist/esm/BeatDetector.js.map +1 -1
  4. package/dist/esm/dsp/tempogram.d.ts +122 -21
  5. package/dist/esm/effects/AutoWahEffect.d.ts +127 -0
  6. package/dist/esm/effects/AutoWahEffect.js +241 -0
  7. package/dist/esm/effects/AutoWahEffect.js.map +1 -0
  8. package/dist/esm/effects/BitCrusherEffect.d.ts +63 -0
  9. package/dist/esm/effects/BitCrusherEffect.js +74 -0
  10. package/dist/esm/effects/BitCrusherEffect.js.map +1 -0
  11. package/dist/esm/effects/ConvolutionEffect.d.ts +114 -0
  12. package/dist/esm/effects/ConvolutionEffect.js +193 -0
  13. package/dist/esm/effects/ConvolutionEffect.js.map +1 -0
  14. package/dist/esm/effects/DistortionEffect.d.ts +119 -0
  15. package/dist/esm/effects/DistortionEffect.js +199 -0
  16. package/dist/esm/effects/DistortionEffect.js.map +1 -0
  17. package/dist/esm/effects/DuckingEffect.js +6 -2
  18. package/dist/esm/effects/DuckingEffect.js.map +1 -1
  19. package/dist/esm/effects/FlangerEffect.d.ts +98 -0
  20. package/dist/esm/effects/FlangerEffect.js +205 -0
  21. package/dist/esm/effects/FlangerEffect.js.map +1 -0
  22. package/dist/esm/effects/GranularEffect.d.ts +8 -4
  23. package/dist/esm/effects/GranularEffect.js +4 -12
  24. package/dist/esm/effects/GranularEffect.js.map +1 -1
  25. package/dist/esm/effects/LimiterEffect.d.ts +124 -0
  26. package/dist/esm/effects/LimiterEffect.js +198 -0
  27. package/dist/esm/effects/LimiterEffect.js.map +1 -0
  28. package/dist/esm/effects/PhaserEffect.d.ts +126 -0
  29. package/dist/esm/effects/PhaserEffect.js +258 -0
  30. package/dist/esm/effects/PhaserEffect.js.map +1 -0
  31. package/dist/esm/effects/PingPongDelayEffect.d.ts +83 -0
  32. package/dist/esm/effects/PingPongDelayEffect.js +189 -0
  33. package/dist/esm/effects/PingPongDelayEffect.js.map +1 -0
  34. package/dist/esm/effects/PitchShiftEffect.d.ts +14 -13
  35. package/dist/esm/effects/PitchShiftEffect.js +16 -18
  36. package/dist/esm/effects/PitchShiftEffect.js.map +1 -1
  37. package/dist/esm/effects/RingModulatorEffect.d.ts +95 -0
  38. package/dist/esm/effects/RingModulatorEffect.js +165 -0
  39. package/dist/esm/effects/RingModulatorEffect.js.map +1 -0
  40. package/dist/esm/effects/TremoloEffect.d.ts +110 -0
  41. package/dist/esm/effects/TremoloEffect.js +205 -0
  42. package/dist/esm/effects/TremoloEffect.js.map +1 -0
  43. package/dist/esm/effects/VocoderEffect.d.ts +0 -4
  44. package/dist/esm/effects/VocoderEffect.js +1 -11
  45. package/dist/esm/effects/VocoderEffect.js.map +1 -1
  46. package/dist/esm/index.d.ts +10 -0
  47. package/dist/esm/index.js +10 -0
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/worklets/beat-detector.worklet.d.ts +1 -1
  50. package/dist/esm/worklets/beat-detector.worklet.js +628 -112
  51. package/dist/esm/worklets/beat-detector.worklet.js.map +1 -1
  52. package/dist/esm/worklets/bit-crusher.worklet.d.ts +1 -0
  53. package/dist/esm/worklets/bit-crusher.worklet.js +45 -0
  54. package/dist/esm/worklets/bit-crusher.worklet.js.map +1 -0
  55. package/dist/esm/worklets/granular.worklet.d.ts +1 -1
  56. package/dist/esm/worklets/granular.worklet.js +13 -4
  57. package/dist/esm/worklets/granular.worklet.js.map +1 -1
  58. package/dist/esm/worklets/pitch-shift.worklet.d.ts +1 -1
  59. package/dist/esm/worklets/pitch-shift.worklet.js +87 -32
  60. package/dist/esm/worklets/pitch-shift.worklet.js.map +1 -1
  61. package/dist/esm/worklets/vocoder.worklet.d.ts +1 -1
  62. package/dist/esm/worklets/vocoder.worklet.js +5 -3
  63. package/dist/esm/worklets/vocoder.worklet.js.map +1 -1
  64. package/package.json +3 -3
@@ -0,0 +1,126 @@
1
+ import { AudioEffect } from '@codexo/exojs';
2
+ /** Construction options for {@link PhaserEffect}. */
3
+ export interface PhaserEffectOptions {
4
+ /**
5
+ * Number of allpass filter stages. Must be an even integer in the range
6
+ * 2..12. Odd values are rounded up to the next even number. Default 4.
7
+ */
8
+ stages?: number;
9
+ /**
10
+ * LFO sweep rate in Hz. Range 0..20, default 0.5.
11
+ */
12
+ rateHz?: number;
13
+ /**
14
+ * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.
15
+ */
16
+ baseFrequency?: number;
17
+ /**
18
+ * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,
19
+ * default 0.6. The LFO peak deviation equals `depth × baseFrequency` Hz,
20
+ * so the filter frequencies sweep between
21
+ * `baseFrequency ± depth × baseFrequency`.
22
+ */
23
+ depth?: number;
24
+ /**
25
+ * Feedback gain from the last stage back to the first stage. Range 0..0.9,
26
+ * default 0.3. Higher values add resonance and sharpen the notch sweep.
27
+ */
28
+ feedback?: number;
29
+ /**
30
+ * Dry/wet mix, 0..1. The dry level is automatically `1 - wet`. Default 0.5.
31
+ */
32
+ wet?: number;
33
+ }
34
+ /**
35
+ * Phaser effect implemented with native Web Audio nodes (no worklet required).
36
+ *
37
+ * The wet signal passes through a cascade of allpass `BiquadFilterNode`s whose
38
+ * centre frequencies are swept synchronously by a sine LFO. The phase shift
39
+ * produced by each allpass stage creates sweeping notches when summed with the
40
+ * dry signal. An optional feedback path from the last stage back to the first
41
+ * adds resonance and sharpens the effect.
42
+ *
43
+ * Node graph:
44
+ * ```
45
+ * inputGain ┬── dryGain ───────────────────────────────────────┐
46
+ * │ ├── outputGain
47
+ * └── allpass[0] ─► … ─► allpass[N-1] ── wetGain ───┘
48
+ * ▲ │
49
+ * └── feedbackDelay ◄── feedbackGain ◄─────────┘
50
+ *
51
+ * lfoOscillator ── lfoGain (depth × baseFrequency Hz) ──► each allpass.frequency
52
+ * ```
53
+ * Note: `feedbackDelay` is a {@link DelayNode} with `delayTime = 0`. Even at
54
+ * zero delay the node itself breaks the zero-latency cycle, which spec-compliant
55
+ * browsers (Chrome, Edge, Safari) would otherwise mute entirely.
56
+ * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`;
57
+ * `feedbackGain.gain = feedback`; `lfoGain.gain = depth × baseFrequency`.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const phaser = new PhaserEffect({ stages: 6, rateHz: 0.3, depth: 0.8, wet: 0.6 });
62
+ * bus.addEffect(phaser);
63
+ *
64
+ * // Automate the rate at runtime
65
+ * phaser.rateHz = 1.2;
66
+ * ```
67
+ */
68
+ export declare class PhaserEffect extends AudioEffect {
69
+ private _setup;
70
+ private _stages;
71
+ private _rateHz;
72
+ private _baseFrequency;
73
+ private _depth;
74
+ private _feedback;
75
+ private _wet;
76
+ private readonly _onAudioContextReady;
77
+ constructor(options?: PhaserEffectOptions);
78
+ /**
79
+ * The node where audio enters this effect. Throws if the audio context is
80
+ * not yet initialized.
81
+ */
82
+ get inputNode(): AudioNode;
83
+ /**
84
+ * The node where audio exits this effect. Throws if the audio context is
85
+ * not yet initialized.
86
+ */
87
+ get outputNode(): AudioNode;
88
+ /**
89
+ * Number of allpass filter stages (even integer, 2..12). Set at construction
90
+ * time only; read-only at runtime.
91
+ */
92
+ get stages(): number;
93
+ /**
94
+ * LFO sweep rate in Hz. Range 0..20, default 0.5. Changes are ramped
95
+ * smoothly via `setTargetAtTime`.
96
+ */
97
+ get rateHz(): number;
98
+ set rateHz(value: number);
99
+ /**
100
+ * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.
101
+ * Changes are ramped smoothly and update both the filter frequencies and the
102
+ * absolute LFO depth.
103
+ */
104
+ get baseFrequency(): number;
105
+ set baseFrequency(value: number);
106
+ /**
107
+ * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,
108
+ * default 0.6. Changes are ramped smoothly via `setTargetAtTime`.
109
+ */
110
+ get depth(): number;
111
+ set depth(value: number);
112
+ /**
113
+ * Feedback gain from the last stage back to the first. Range 0..0.9,
114
+ * default 0.3. Changes are ramped smoothly via `setTargetAtTime`.
115
+ */
116
+ get feedback(): number;
117
+ set feedback(value: number);
118
+ /**
119
+ * Wet (phased) mix level, 0..1. The dry level is automatically `1 - wet`.
120
+ * Changes are ramped smoothly via `setTargetAtTime`. Default 0.5.
121
+ */
122
+ get wet(): number;
123
+ set wet(value: number);
124
+ destroy(): void;
125
+ private _setupNodes;
126
+ }
@@ -0,0 +1,258 @@
1
+ import { AudioEffect, onAudioContextReady, isAudioContextReady, getAudioContext } from '@codexo/exojs';
2
+
3
+ /**
4
+ * Phaser effect implemented with native Web Audio nodes (no worklet required).
5
+ *
6
+ * The wet signal passes through a cascade of allpass `BiquadFilterNode`s whose
7
+ * centre frequencies are swept synchronously by a sine LFO. The phase shift
8
+ * produced by each allpass stage creates sweeping notches when summed with the
9
+ * dry signal. An optional feedback path from the last stage back to the first
10
+ * adds resonance and sharpens the effect.
11
+ *
12
+ * Node graph:
13
+ * ```
14
+ * inputGain ┬── dryGain ───────────────────────────────────────┐
15
+ * │ ├── outputGain
16
+ * └── allpass[0] ─► … ─► allpass[N-1] ── wetGain ───┘
17
+ * ▲ │
18
+ * └── feedbackDelay ◄── feedbackGain ◄─────────┘
19
+ *
20
+ * lfoOscillator ── lfoGain (depth × baseFrequency Hz) ──► each allpass.frequency
21
+ * ```
22
+ * Note: `feedbackDelay` is a {@link DelayNode} with `delayTime = 0`. Even at
23
+ * zero delay the node itself breaks the zero-latency cycle, which spec-compliant
24
+ * browsers (Chrome, Edge, Safari) would otherwise mute entirely.
25
+ * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`;
26
+ * `feedbackGain.gain = feedback`; `lfoGain.gain = depth × baseFrequency`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const phaser = new PhaserEffect({ stages: 6, rateHz: 0.3, depth: 0.8, wet: 0.6 });
31
+ * bus.addEffect(phaser);
32
+ *
33
+ * // Automate the rate at runtime
34
+ * phaser.rateHz = 1.2;
35
+ * ```
36
+ */
37
+ class PhaserEffect extends AudioEffect {
38
+ _setup = null;
39
+ _stages;
40
+ _rateHz;
41
+ _baseFrequency;
42
+ _depth;
43
+ _feedback;
44
+ _wet;
45
+ _onAudioContextReady = (ctx) => {
46
+ onAudioContextReady.remove(this._onAudioContextReady);
47
+ this._setupNodes(ctx);
48
+ };
49
+ constructor(options = {}) {
50
+ super();
51
+ const rawStages = Math.max(2, Math.min(12, Math.round(options.stages ?? 4)));
52
+ this._stages = rawStages % 2 !== 0 ? Math.min(12, rawStages + 1) : rawStages;
53
+ this._rateHz = Math.max(0, Math.min(20, options.rateHz ?? 0.5));
54
+ this._baseFrequency = Math.max(50, Math.min(5000, options.baseFrequency ?? 500));
55
+ this._depth = Math.max(0, Math.min(1, options.depth ?? 0.6));
56
+ this._feedback = Math.max(0, Math.min(0.9, options.feedback ?? 0.3));
57
+ this._wet = Math.max(0, Math.min(1, options.wet ?? 0.5));
58
+ if (isAudioContextReady()) {
59
+ this._setupNodes(getAudioContext());
60
+ }
61
+ else {
62
+ onAudioContextReady.add(this._onAudioContextReady);
63
+ }
64
+ }
65
+ /**
66
+ * The node where audio enters this effect. Throws if the audio context is
67
+ * not yet initialized.
68
+ */
69
+ get inputNode() {
70
+ if (!this._setup)
71
+ throw new Error('PhaserEffect not yet initialized.');
72
+ return this._setup.inputGain;
73
+ }
74
+ /**
75
+ * The node where audio exits this effect. Throws if the audio context is
76
+ * not yet initialized.
77
+ */
78
+ get outputNode() {
79
+ if (!this._setup)
80
+ throw new Error('PhaserEffect not yet initialized.');
81
+ return this._setup.outputGain;
82
+ }
83
+ // ---------------------------------------------------------------------------
84
+ // Getters / setters
85
+ // ---------------------------------------------------------------------------
86
+ /**
87
+ * Number of allpass filter stages (even integer, 2..12). Set at construction
88
+ * time only; read-only at runtime.
89
+ */
90
+ get stages() {
91
+ return this._stages;
92
+ }
93
+ /**
94
+ * LFO sweep rate in Hz. Range 0..20, default 0.5. Changes are ramped
95
+ * smoothly via `setTargetAtTime`.
96
+ */
97
+ get rateHz() {
98
+ return this._rateHz;
99
+ }
100
+ set rateHz(value) {
101
+ this._rateHz = Math.max(0, Math.min(20, value));
102
+ if (this._setup) {
103
+ this._setup.lfoOscillator.frequency.setTargetAtTime(this._rateHz, this._setup.inputGain.context.currentTime, 0.01);
104
+ }
105
+ }
106
+ /**
107
+ * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.
108
+ * Changes are ramped smoothly and update both the filter frequencies and the
109
+ * absolute LFO depth.
110
+ */
111
+ get baseFrequency() {
112
+ return this._baseFrequency;
113
+ }
114
+ set baseFrequency(value) {
115
+ this._baseFrequency = Math.max(50, Math.min(5000, value));
116
+ if (this._setup) {
117
+ const ctx = this._setup.inputGain.context;
118
+ for (const filter of this._setup.allpassFilters) {
119
+ filter.frequency.setTargetAtTime(this._baseFrequency, ctx.currentTime, 0.01);
120
+ }
121
+ this._setup.lfoGain.gain.setTargetAtTime(this._depth * this._baseFrequency, ctx.currentTime, 0.01);
122
+ }
123
+ }
124
+ /**
125
+ * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,
126
+ * default 0.6. Changes are ramped smoothly via `setTargetAtTime`.
127
+ */
128
+ get depth() {
129
+ return this._depth;
130
+ }
131
+ set depth(value) {
132
+ this._depth = Math.max(0, Math.min(1, value));
133
+ if (this._setup) {
134
+ this._setup.lfoGain.gain.setTargetAtTime(this._depth * this._baseFrequency, this._setup.inputGain.context.currentTime, 0.01);
135
+ }
136
+ }
137
+ /**
138
+ * Feedback gain from the last stage back to the first. Range 0..0.9,
139
+ * default 0.3. Changes are ramped smoothly via `setTargetAtTime`.
140
+ */
141
+ get feedback() {
142
+ return this._feedback;
143
+ }
144
+ set feedback(value) {
145
+ this._feedback = Math.max(0, Math.min(0.9, value));
146
+ if (this._setup) {
147
+ this._setup.feedbackGain.gain.setTargetAtTime(this._feedback, this._setup.inputGain.context.currentTime, 0.01);
148
+ }
149
+ }
150
+ /**
151
+ * Wet (phased) mix level, 0..1. The dry level is automatically `1 - wet`.
152
+ * Changes are ramped smoothly via `setTargetAtTime`. Default 0.5.
153
+ */
154
+ get wet() {
155
+ return this._wet;
156
+ }
157
+ set wet(value) {
158
+ this._wet = Math.max(0, Math.min(1, value));
159
+ if (this._setup) {
160
+ const ctx = this._setup.wetGain.context;
161
+ this._setup.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, 0.01);
162
+ this._setup.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, 0.01);
163
+ }
164
+ }
165
+ // ---------------------------------------------------------------------------
166
+ // Lifecycle
167
+ // ---------------------------------------------------------------------------
168
+ destroy() {
169
+ onAudioContextReady.remove(this._onAudioContextReady);
170
+ if (this._setup) {
171
+ this._setup.lfoOscillator.stop();
172
+ this._setup.lfoOscillator.disconnect();
173
+ this._setup.lfoGain.disconnect();
174
+ for (const filter of this._setup.allpassFilters) {
175
+ filter.disconnect();
176
+ }
177
+ this._setup.feedbackGain.disconnect();
178
+ this._setup.feedbackDelay.disconnect();
179
+ this._setup.dryGain.disconnect();
180
+ this._setup.wetGain.disconnect();
181
+ this._setup.inputGain.disconnect();
182
+ this._setup.outputGain.disconnect();
183
+ this._setup = null;
184
+ }
185
+ }
186
+ // ---------------------------------------------------------------------------
187
+ // Private
188
+ // ---------------------------------------------------------------------------
189
+ _setupNodes(ctx) {
190
+ const inputGain = ctx.createGain();
191
+ const outputGain = ctx.createGain();
192
+ const dryGain = ctx.createGain();
193
+ const wetGain = ctx.createGain();
194
+ const feedbackGain = ctx.createGain();
195
+ const lfoGain = ctx.createGain();
196
+ // A zero-length DelayNode in the feedback path is required so that
197
+ // spec-compliant browsers do not mute the entire allpass chain. Browsers
198
+ // are permitted to silence feedback cycles that contain no DelayNode (i.e.
199
+ // zero-latency cycles), so even delayTime=0 here is sufficient to make the
200
+ // cycle legal — the DelayNode itself introduces at least one render-quantum
201
+ // of delay regardless of its delayTime parameter.
202
+ const feedbackDelay = ctx.createDelay(1);
203
+ feedbackDelay.delayTime.setValueAtTime(0, ctx.currentTime);
204
+ inputGain.gain.setValueAtTime(1, ctx.currentTime);
205
+ outputGain.gain.setValueAtTime(1, ctx.currentTime);
206
+ dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);
207
+ wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);
208
+ feedbackGain.gain.setValueAtTime(this._feedback, ctx.currentTime);
209
+ lfoGain.gain.setValueAtTime(this._depth * this._baseFrequency, ctx.currentTime);
210
+ // Allpass filter cascade
211
+ const allpassFilters = [];
212
+ for (let i = 0; i < this._stages; i++) {
213
+ const filter = ctx.createBiquadFilter();
214
+ filter.type = 'allpass';
215
+ filter.frequency.setValueAtTime(this._baseFrequency, ctx.currentTime);
216
+ allpassFilters.push(filter);
217
+ }
218
+ // LFO oscillator
219
+ const lfoOscillator = ctx.createOscillator();
220
+ lfoOscillator.type = 'sine';
221
+ lfoOscillator.frequency.value = this._rateHz;
222
+ // LFO wiring: lfoOscillator → lfoGain → each allpass.frequency (AudioParam)
223
+ lfoOscillator.connect(lfoGain);
224
+ for (const filter of allpassFilters) {
225
+ lfoGain.connect(filter.frequency);
226
+ }
227
+ // Dry path: inputGain → dryGain → outputGain
228
+ inputGain.connect(dryGain);
229
+ dryGain.connect(outputGain);
230
+ // Wet path: inputGain → allpass[0] → … → allpass[N-1] → wetGain → outputGain
231
+ inputGain.connect(allpassFilters[0]);
232
+ for (let i = 0; i < allpassFilters.length - 1; i++) {
233
+ allpassFilters[i].connect(allpassFilters[i + 1]);
234
+ }
235
+ allpassFilters[allpassFilters.length - 1].connect(wetGain);
236
+ wetGain.connect(outputGain);
237
+ // Feedback path: allpass[N-1] → feedbackGain → feedbackDelay → allpass[0]
238
+ // feedbackDelay breaks the zero-latency cycle so browsers do not mute the chain.
239
+ allpassFilters[allpassFilters.length - 1].connect(feedbackGain);
240
+ feedbackGain.connect(feedbackDelay);
241
+ feedbackDelay.connect(allpassFilters[0]);
242
+ lfoOscillator.start();
243
+ this._setup = {
244
+ inputGain,
245
+ outputGain,
246
+ dryGain,
247
+ wetGain,
248
+ feedbackGain,
249
+ feedbackDelay,
250
+ lfoGain,
251
+ allpassFilters,
252
+ lfoOscillator,
253
+ };
254
+ }
255
+ }
256
+
257
+ export { PhaserEffect };
258
+ //# sourceMappingURL=PhaserEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhaserEffect.js","sources":["../../../../src/effects/PhaserEffect.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACG,MAAO,YAAa,SAAQ,WAAW,CAAA;IACnC,MAAM,GAA6B,IAAI;AACvC,IAAA,OAAO;AACP,IAAA,OAAO;AACP,IAAA,cAAc;AACd,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,IAAI;AACK,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,UAA+B,EAAE,EAAA;AAClD,QAAA,KAAK,EAAE;QACP,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,OAAO,GAAG,SAAS,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS;QAC5E,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAA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Z,SAAS;YACT,UAAU;YACV,OAAO;YACP,OAAO;YACP,YAAY;YACZ,aAAa;YACb,OAAO;YACP,cAAc;YACd,aAAa;SACd;IACH;AACD;;;;"}
@@ -0,0 +1,83 @@
1
+ import { AudioEffect } from '@codexo/exojs';
2
+ /** Construction options for {@link PingPongDelayEffect}. */
3
+ export interface PingPongDelayEffectOptions {
4
+ /**
5
+ * Delay time per tap in seconds. Range 0.01..2, default 0.25.
6
+ */
7
+ delayTime?: number;
8
+ /**
9
+ * Cross-channel feedback fraction — the portion of each delayed tap routed
10
+ * into the opposite channel's delay input. Range 0..0.9, default 0.4.
11
+ */
12
+ feedback?: number;
13
+ /**
14
+ * Dry/wet mix, 0..1. The dry level is automatically `1 - wet`. Default 0.4.
15
+ */
16
+ wet?: number;
17
+ }
18
+ /**
19
+ * Stereo ping-pong delay effect using two cross-fed {@link DelayNode}s that
20
+ * bounce the signal alternately between left and right channels. The input
21
+ * feeds only the left delay; cross-feedback (L→R and R→L) then causes the
22
+ * signal to alternate channels on every tap, producing the characteristic L↔R
23
+ * slapback cascade. Each tap is routed through a {@link StereoPannerNode}
24
+ * panned hard left or right, maintaining hard-left / hard-right stereo
25
+ * separation throughout the feedback tail.
26
+ *
27
+ * Node graph:
28
+ * ```
29
+ * input(GainNode) → dryGain ────────────────────────────────── output(GainNode)
30
+ * input → delayL → feedbackGainA → delayR ↑
31
+ * delayR → feedbackGainB → delayL │
32
+ * delayL → pannerL (pan = -1, hard left) → wetGain ─────────┘
33
+ * delayR → pannerR (pan = +1, hard right) → wetGain
34
+ * ```
35
+ * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const pingPong = new PingPongDelayEffect({ delayTime: 0.3, feedback: 0.5, wet: 0.5 });
40
+ * bus.addEffect(pingPong);
41
+ * ```
42
+ */
43
+ export declare class PingPongDelayEffect extends AudioEffect {
44
+ private _setup;
45
+ private _delayTime;
46
+ private _feedback;
47
+ private _wet;
48
+ private readonly _onAudioContextReady;
49
+ constructor(options?: PingPongDelayEffectOptions);
50
+ /**
51
+ * The node where audio enters this effect. Throws if the audio context is
52
+ * not yet initialized.
53
+ */
54
+ get inputNode(): AudioNode;
55
+ /**
56
+ * The node where audio exits this effect. Throws if the audio context is
57
+ * not yet initialized.
58
+ */
59
+ get outputNode(): AudioNode;
60
+ /**
61
+ * Delay time per tap in seconds. Both the left and right delay nodes share
62
+ * the same delay time. Range 0.01..2, default 0.25.
63
+ * Changes are ramped smoothly via `setTargetAtTime`.
64
+ */
65
+ get delayTime(): number;
66
+ set delayTime(value: number);
67
+ /**
68
+ * Cross-channel feedback fraction. Each delayed tap feeds this fraction of
69
+ * its signal into the opposite channel's delay, sustaining the L↔R bounce.
70
+ * Range 0..0.9, default 0.4. Changes are ramped smoothly via
71
+ * `setTargetAtTime`.
72
+ */
73
+ get feedback(): number;
74
+ set feedback(value: number);
75
+ /**
76
+ * Wet (ping-pong) mix level, 0..1. The dry level is automatically `1 - wet`.
77
+ * Changes are ramped smoothly via `setTargetAtTime`. Default 0.4.
78
+ */
79
+ get wet(): number;
80
+ set wet(value: number);
81
+ destroy(): void;
82
+ private _setupNodes;
83
+ }
@@ -0,0 +1,189 @@
1
+ import { AudioEffect, onAudioContextReady, isAudioContextReady, getAudioContext } from '@codexo/exojs';
2
+
3
+ /**
4
+ * Stereo ping-pong delay effect using two cross-fed {@link DelayNode}s that
5
+ * bounce the signal alternately between left and right channels. The input
6
+ * feeds only the left delay; cross-feedback (L→R and R→L) then causes the
7
+ * signal to alternate channels on every tap, producing the characteristic L↔R
8
+ * slapback cascade. Each tap is routed through a {@link StereoPannerNode}
9
+ * panned hard left or right, maintaining hard-left / hard-right stereo
10
+ * separation throughout the feedback tail.
11
+ *
12
+ * Node graph:
13
+ * ```
14
+ * input(GainNode) → dryGain ────────────────────────────────── output(GainNode)
15
+ * input → delayL → feedbackGainA → delayR ↑
16
+ * delayR → feedbackGainB → delayL │
17
+ * delayL → pannerL (pan = -1, hard left) → wetGain ─────────┘
18
+ * delayR → pannerR (pan = +1, hard right) → wetGain
19
+ * ```
20
+ * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const pingPong = new PingPongDelayEffect({ delayTime: 0.3, feedback: 0.5, wet: 0.5 });
25
+ * bus.addEffect(pingPong);
26
+ * ```
27
+ */
28
+ class PingPongDelayEffect extends AudioEffect {
29
+ _setup = null;
30
+ _delayTime;
31
+ _feedback;
32
+ _wet;
33
+ _onAudioContextReady = (ctx) => {
34
+ onAudioContextReady.remove(this._onAudioContextReady);
35
+ this._setupNodes(ctx);
36
+ };
37
+ constructor(options = {}) {
38
+ super();
39
+ this._delayTime = Math.max(0.01, Math.min(2, options.delayTime ?? 0.25));
40
+ this._feedback = Math.max(0, Math.min(0.9, options.feedback ?? 0.4));
41
+ this._wet = Math.max(0, Math.min(1, options.wet ?? 0.4));
42
+ if (isAudioContextReady()) {
43
+ this._setupNodes(getAudioContext());
44
+ }
45
+ else {
46
+ onAudioContextReady.add(this._onAudioContextReady);
47
+ }
48
+ }
49
+ /**
50
+ * The node where audio enters this effect. Throws if the audio context is
51
+ * not yet initialized.
52
+ */
53
+ get inputNode() {
54
+ if (!this._setup)
55
+ throw new Error('PingPongDelayEffect not yet initialized.');
56
+ return this._setup.inputGain;
57
+ }
58
+ /**
59
+ * The node where audio exits this effect. Throws if the audio context is
60
+ * not yet initialized.
61
+ */
62
+ get outputNode() {
63
+ if (!this._setup)
64
+ throw new Error('PingPongDelayEffect not yet initialized.');
65
+ return this._setup.outputGain;
66
+ }
67
+ /**
68
+ * Delay time per tap in seconds. Both the left and right delay nodes share
69
+ * the same delay time. Range 0.01..2, default 0.25.
70
+ * Changes are ramped smoothly via `setTargetAtTime`.
71
+ */
72
+ get delayTime() {
73
+ return this._delayTime;
74
+ }
75
+ set delayTime(value) {
76
+ this._delayTime = Math.max(0.01, Math.min(2, value));
77
+ if (this._setup) {
78
+ const time = this._setup.delayL.context.currentTime;
79
+ this._setup.delayL.delayTime.setTargetAtTime(this._delayTime, time, 0.01);
80
+ this._setup.delayR.delayTime.setTargetAtTime(this._delayTime, time, 0.01);
81
+ }
82
+ }
83
+ /**
84
+ * Cross-channel feedback fraction. Each delayed tap feeds this fraction of
85
+ * its signal into the opposite channel's delay, sustaining the L↔R bounce.
86
+ * Range 0..0.9, default 0.4. Changes are ramped smoothly via
87
+ * `setTargetAtTime`.
88
+ */
89
+ get feedback() {
90
+ return this._feedback;
91
+ }
92
+ set feedback(value) {
93
+ this._feedback = Math.max(0, Math.min(0.9, value));
94
+ if (this._setup) {
95
+ const time = this._setup.feedbackGainA.context.currentTime;
96
+ this._setup.feedbackGainA.gain.setTargetAtTime(this._feedback, time, 0.01);
97
+ this._setup.feedbackGainB.gain.setTargetAtTime(this._feedback, time, 0.01);
98
+ }
99
+ }
100
+ /**
101
+ * Wet (ping-pong) mix level, 0..1. The dry level is automatically `1 - wet`.
102
+ * Changes are ramped smoothly via `setTargetAtTime`. Default 0.4.
103
+ */
104
+ get wet() {
105
+ return this._wet;
106
+ }
107
+ set wet(value) {
108
+ this._wet = Math.max(0, Math.min(1, value));
109
+ if (this._setup) {
110
+ const ctx = this._setup.wetGain.context;
111
+ this._setup.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, 0.01);
112
+ this._setup.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, 0.01);
113
+ }
114
+ }
115
+ destroy() {
116
+ onAudioContextReady.remove(this._onAudioContextReady);
117
+ if (this._setup) {
118
+ this._setup.inputGain.disconnect();
119
+ this._setup.outputGain.disconnect();
120
+ this._setup.dryGain.disconnect();
121
+ this._setup.wetGain.disconnect();
122
+ this._setup.feedbackGainA.disconnect();
123
+ this._setup.feedbackGainB.disconnect();
124
+ this._setup.delayL.disconnect();
125
+ this._setup.delayR.disconnect();
126
+ this._setup.pannerL.disconnect();
127
+ this._setup.pannerR.disconnect();
128
+ this._setup = null;
129
+ }
130
+ }
131
+ _setupNodes(ctx) {
132
+ const inputGain = ctx.createGain();
133
+ const outputGain = ctx.createGain();
134
+ const dryGain = ctx.createGain();
135
+ const wetGain = ctx.createGain();
136
+ const feedbackGainA = ctx.createGain();
137
+ const feedbackGainB = ctx.createGain();
138
+ const delayL = ctx.createDelay(2);
139
+ const delayR = ctx.createDelay(2);
140
+ const pannerL = ctx.createStereoPanner();
141
+ const pannerR = ctx.createStereoPanner();
142
+ inputGain.gain.setValueAtTime(1, ctx.currentTime);
143
+ outputGain.gain.setValueAtTime(1, ctx.currentTime);
144
+ dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);
145
+ wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);
146
+ feedbackGainA.gain.setValueAtTime(this._feedback, ctx.currentTime);
147
+ feedbackGainB.gain.setValueAtTime(this._feedback, ctx.currentTime);
148
+ delayL.delayTime.setValueAtTime(this._delayTime, ctx.currentTime);
149
+ delayR.delayTime.setValueAtTime(this._delayTime, ctx.currentTime);
150
+ // Hard-pan each tap to its respective stereo channel.
151
+ pannerL.pan.value = -1;
152
+ pannerR.pan.value = 1;
153
+ // Dry path: input → dryGain → output
154
+ inputGain.connect(dryGain);
155
+ dryGain.connect(outputGain);
156
+ // Wet path: input feeds only the left delay.
157
+ // Feeding both delays symmetrically would produce identical L/R evolution
158
+ // (no ping-pong). The cross-feedback edges below route each tap into the
159
+ // opposite channel's delay, creating the alternating L↔R slapback.
160
+ inputGain.connect(delayL);
161
+ // Cross-feedback: L → R and R → L
162
+ delayL.connect(feedbackGainA);
163
+ feedbackGainA.connect(delayR);
164
+ delayR.connect(feedbackGainB);
165
+ feedbackGainB.connect(delayL);
166
+ // Pan taps: delayL → pannerL (hard left), delayR → pannerR (hard right)
167
+ delayL.connect(pannerL);
168
+ delayR.connect(pannerR);
169
+ // Wet output: panned taps sum into wetGain → output
170
+ pannerL.connect(wetGain);
171
+ pannerR.connect(wetGain);
172
+ wetGain.connect(outputGain);
173
+ this._setup = {
174
+ inputGain,
175
+ outputGain,
176
+ dryGain,
177
+ wetGain,
178
+ feedbackGainA,
179
+ feedbackGainB,
180
+ delayL,
181
+ delayR,
182
+ pannerL,
183
+ pannerR,
184
+ };
185
+ }
186
+ }
187
+
188
+ export { PingPongDelayEffect };
189
+ //# sourceMappingURL=PingPongDelayEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PingPongDelayEffect.js","sources":["../../../../src/effects/PingPongDelayEffect.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAgCA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACG,MAAO,mBAAoB,SAAQ,WAAW,CAAA;IAC1C,MAAM,GAAoC,IAAI;AAC9C,IAAA,UAAU;AACV,IAAA,SAAS;AACT,IAAA,IAAI;AACK,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,UAAsC,EAAE,EAAA;AACzD,QAAA,KAAK,EAAE;QACP,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;QACxD,IAAI,mBAAmB,EAAE,EAAE;AACzB,YAAA,IAAI,CAAC,WAAW,CAA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