@codexo/exojs-audio-fx 0.19.1 → 0.20.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 (127) hide show
  1. package/README.md +7 -53
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +12 -20
  5. package/dist/esm/AudioAnalyser.d.ts +0 -123
  6. package/dist/esm/AudioAnalyser.d.ts.map +0 -1
  7. package/dist/esm/AudioAnalyser.js +0 -295
  8. package/dist/esm/AudioAnalyser.js.map +0 -1
  9. package/dist/esm/AudioTap.d.ts +0 -33
  10. package/dist/esm/AudioTap.d.ts.map +0 -1
  11. package/dist/esm/AudioTap.js +0 -126
  12. package/dist/esm/AudioTap.js.map +0 -1
  13. package/dist/esm/BeatDetector.d.ts +0 -291
  14. package/dist/esm/BeatDetector.d.ts.map +0 -1
  15. package/dist/esm/BeatDetector.js +0 -365
  16. package/dist/esm/BeatDetector.js.map +0 -1
  17. package/dist/esm/PcmStreamSource.d.ts +0 -132
  18. package/dist/esm/PcmStreamSource.d.ts.map +0 -1
  19. package/dist/esm/PcmStreamSource.js +0 -313
  20. package/dist/esm/PcmStreamSource.js.map +0 -1
  21. package/dist/esm/ReadyGate.d.ts +0 -25
  22. package/dist/esm/ReadyGate.d.ts.map +0 -1
  23. package/dist/esm/ReadyGate.js +0 -69
  24. package/dist/esm/ReadyGate.js.map +0 -1
  25. package/dist/esm/dsp/fft.d.ts +0 -22
  26. package/dist/esm/dsp/fft.d.ts.map +0 -1
  27. package/dist/esm/dsp/mel.d.ts +0 -43
  28. package/dist/esm/dsp/mel.d.ts.map +0 -1
  29. package/dist/esm/dsp/mel.js +0 -61
  30. package/dist/esm/dsp/mel.js.map +0 -1
  31. package/dist/esm/dsp/tempogram.d.ts +0 -192
  32. package/dist/esm/dsp/tempogram.d.ts.map +0 -1
  33. package/dist/esm/effects/AutoWahEffect.d.ts +0 -127
  34. package/dist/esm/effects/AutoWahEffect.d.ts.map +0 -1
  35. package/dist/esm/effects/AutoWahEffect.js +0 -209
  36. package/dist/esm/effects/AutoWahEffect.js.map +0 -1
  37. package/dist/esm/effects/BitCrusherEffect.d.ts +0 -64
  38. package/dist/esm/effects/BitCrusherEffect.d.ts.map +0 -1
  39. package/dist/esm/effects/BitCrusherEffect.js +0 -76
  40. package/dist/esm/effects/BitCrusherEffect.js.map +0 -1
  41. package/dist/esm/effects/ChorusEffect.d.ts +0 -60
  42. package/dist/esm/effects/ChorusEffect.d.ts.map +0 -1
  43. package/dist/esm/effects/ChorusEffect.js +0 -139
  44. package/dist/esm/effects/ChorusEffect.js.map +0 -1
  45. package/dist/esm/effects/CompressorEffect.d.ts +0 -55
  46. package/dist/esm/effects/CompressorEffect.d.ts.map +0 -1
  47. package/dist/esm/effects/CompressorEffect.js +0 -103
  48. package/dist/esm/effects/CompressorEffect.js.map +0 -1
  49. package/dist/esm/effects/ConvolutionEffect.d.ts +0 -118
  50. package/dist/esm/effects/ConvolutionEffect.d.ts.map +0 -1
  51. package/dist/esm/effects/ConvolutionEffect.js +0 -207
  52. package/dist/esm/effects/ConvolutionEffect.js.map +0 -1
  53. package/dist/esm/effects/DelayEffect.d.ts +0 -35
  54. package/dist/esm/effects/DelayEffect.d.ts.map +0 -1
  55. package/dist/esm/effects/DelayEffect.js +0 -104
  56. package/dist/esm/effects/DelayEffect.js.map +0 -1
  57. package/dist/esm/effects/DistortionEffect.d.ts +0 -116
  58. package/dist/esm/effects/DistortionEffect.d.ts.map +0 -1
  59. package/dist/esm/effects/DistortionEffect.js +0 -189
  60. package/dist/esm/effects/DistortionEffect.js.map +0 -1
  61. package/dist/esm/effects/DuckingEffect.d.ts +0 -44
  62. package/dist/esm/effects/DuckingEffect.d.ts.map +0 -1
  63. package/dist/esm/effects/DuckingEffect.js +0 -89
  64. package/dist/esm/effects/DuckingEffect.js.map +0 -1
  65. package/dist/esm/effects/EqualizerEffect.d.ts +0 -50
  66. package/dist/esm/effects/EqualizerEffect.d.ts.map +0 -1
  67. package/dist/esm/effects/EqualizerEffect.js +0 -119
  68. package/dist/esm/effects/EqualizerEffect.js.map +0 -1
  69. package/dist/esm/effects/FlangerEffect.d.ts +0 -107
  70. package/dist/esm/effects/FlangerEffect.d.ts.map +0 -1
  71. package/dist/esm/effects/FlangerEffect.js +0 -178
  72. package/dist/esm/effects/FlangerEffect.js.map +0 -1
  73. package/dist/esm/effects/GranularEffect.d.ts +0 -67
  74. package/dist/esm/effects/GranularEffect.d.ts.map +0 -1
  75. package/dist/esm/effects/GranularEffect.js +0 -104
  76. package/dist/esm/effects/GranularEffect.js.map +0 -1
  77. package/dist/esm/effects/LimiterEffect.d.ts +0 -129
  78. package/dist/esm/effects/LimiterEffect.d.ts.map +0 -1
  79. package/dist/esm/effects/LimiterEffect.js +0 -185
  80. package/dist/esm/effects/LimiterEffect.js.map +0 -1
  81. package/dist/esm/effects/PhaserEffect.d.ts +0 -126
  82. package/dist/esm/effects/PhaserEffect.d.ts.map +0 -1
  83. package/dist/esm/effects/PhaserEffect.js +0 -213
  84. package/dist/esm/effects/PhaserEffect.js.map +0 -1
  85. package/dist/esm/effects/PingPongDelayEffect.d.ts +0 -83
  86. package/dist/esm/effects/PingPongDelayEffect.d.ts.map +0 -1
  87. package/dist/esm/effects/PingPongDelayEffect.js +0 -171
  88. package/dist/esm/effects/PingPongDelayEffect.js.map +0 -1
  89. package/dist/esm/effects/PitchShiftEffect.d.ts +0 -46
  90. package/dist/esm/effects/PitchShiftEffect.d.ts.map +0 -1
  91. package/dist/esm/effects/PitchShiftEffect.js +0 -64
  92. package/dist/esm/effects/PitchShiftEffect.js.map +0 -1
  93. package/dist/esm/effects/ReverbEffect.d.ts +0 -37
  94. package/dist/esm/effects/ReverbEffect.d.ts.map +0 -1
  95. package/dist/esm/effects/ReverbEffect.js +0 -112
  96. package/dist/esm/effects/ReverbEffect.js.map +0 -1
  97. package/dist/esm/effects/RingModulatorEffect.d.ts +0 -95
  98. package/dist/esm/effects/RingModulatorEffect.d.ts.map +0 -1
  99. package/dist/esm/effects/RingModulatorEffect.js +0 -152
  100. package/dist/esm/effects/RingModulatorEffect.js.map +0 -1
  101. package/dist/esm/effects/TremoloEffect.d.ts +0 -108
  102. package/dist/esm/effects/TremoloEffect.d.ts.map +0 -1
  103. package/dist/esm/effects/TremoloEffect.js +0 -192
  104. package/dist/esm/effects/TremoloEffect.js.map +0 -1
  105. package/dist/esm/effects/VocoderEffect.d.ts +0 -45
  106. package/dist/esm/effects/VocoderEffect.d.ts.map +0 -1
  107. package/dist/esm/effects/VocoderEffect.js +0 -68
  108. package/dist/esm/effects/VocoderEffect.js.map +0 -1
  109. package/dist/esm/index.d.ts +0 -25
  110. package/dist/esm/index.d.ts.map +0 -1
  111. package/dist/esm/index.js +0 -24
  112. package/dist/esm/worklets/beat-detector.worklet.js +0 -6
  113. package/dist/esm/worklets/beat-detector.worklet.js.map +0 -1
  114. package/dist/esm/worklets/bit-crusher.worklet.js +0 -6
  115. package/dist/esm/worklets/bit-crusher.worklet.js.map +0 -1
  116. package/dist/esm/worklets/disposable-processor.d.ts +0 -13
  117. package/dist/esm/worklets/disposable-processor.d.ts.map +0 -1
  118. package/dist/esm/worklets/ducking.worklet.js +0 -6
  119. package/dist/esm/worklets/ducking.worklet.js.map +0 -1
  120. package/dist/esm/worklets/granular.worklet.js +0 -6
  121. package/dist/esm/worklets/granular.worklet.js.map +0 -1
  122. package/dist/esm/worklets/pcm-stream.worklet.js +0 -6
  123. package/dist/esm/worklets/pcm-stream.worklet.js.map +0 -1
  124. package/dist/esm/worklets/pitch-shift.worklet.js +0 -6
  125. package/dist/esm/worklets/pitch-shift.worklet.js.map +0 -1
  126. package/dist/esm/worklets/vocoder.worklet.js +0 -6
  127. package/dist/esm/worklets/vocoder.worklet.js.map +0 -1
@@ -1,185 +0,0 @@
1
- import { AudioEffect } from "@codexo/exojs";
2
-
3
- //#region src/effects/LimiterEffect.ts
4
- /**
5
- * Limiter-style compressor backed by a Web Audio `DynamicsCompressorNode` set
6
- * for hard limiting: the highest ratio the node allows (20), zero knee (hard
7
- * knee), and a fast attack. Use it at the end of a chain to tame peaks.
8
- *
9
- * It is not a brick-wall peak limiter: the node has no lookahead, so a
10
- * transient faster than `attack` passes before gain reduction engages, and
11
- * above the threshold the level still rises by 1 dB per 20 dB of input.
12
- * Leave headroom below 0 dBFS rather than relying on it to stop every clip.
13
- *
14
- * The compressor `ratio` and `knee` default to the hardest values (20 and 0
15
- * respectively) but remain configurable, unlike a truly fixed limiter,
16
- * because callers occasionally want a softer, more compressor-like limiting
17
- * curve (lower ratio) or a gentler transition into limiting (larger knee)
18
- * without switching to {@link CompressorEffect} and losing the dry/wet mix.
19
- * The effect also exposes a dry/wet mix for API consistency and parallel
20
- * processing workflows, though a fully-wet signal (`wet = 1`) is the typical
21
- * configuration.
22
- *
23
- * Node graph:
24
- * ```
25
- * input(GainNode) → dryGain → output(GainNode)
26
- * input → compressor → wetGain → output
27
- * ```
28
- * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`.
29
- *
30
- * @example
31
- * ```ts
32
- * const limiter = new LimiterEffect({ threshold: -3, release: 0.1 });
33
- * masterBus.addEffect(limiter);
34
- * ```
35
- */
36
- var LimiterEffect = class extends AudioEffect {
37
- _setup = null;
38
- _threshold;
39
- _attack;
40
- _release;
41
- _wet;
42
- _ratio;
43
- _knee;
44
- constructor(options = {}) {
45
- super();
46
- this._threshold = Math.max(-60, Math.min(0, options.threshold ?? -3));
47
- this._attack = Math.max(0, Math.min(1, options.attack ?? .003));
48
- this._release = Math.max(0, Math.min(1, options.release ?? .25));
49
- this._wet = Math.max(0, Math.min(1, options.wet ?? 1));
50
- this._ratio = Math.max(1, Math.min(20, options.ratio ?? 20));
51
- this._knee = Math.max(0, Math.min(40, options.knee ?? 0));
52
- this._deferSetup((context) => this._setupNodes(context));
53
- }
54
- /**
55
- * The node where audio enters this effect. Throws if the audio context is
56
- * not yet initialized.
57
- */
58
- get inputNode() {
59
- if (!this._setup) throw new Error("LimiterEffect not yet initialized.");
60
- return this._setup.inputGain;
61
- }
62
- /**
63
- * The node where audio exits this effect. Throws if the audio context is
64
- * not yet initialized.
65
- */
66
- get outputNode() {
67
- if (!this._setup) throw new Error("LimiterEffect not yet initialized.");
68
- return this._setup.outputGain;
69
- }
70
- /**
71
- * Threshold in dBFS above which limiting is applied. Range −60..0, default −3.
72
- * Changes are ramped smoothly via `setTargetAtTime`.
73
- */
74
- get threshold() {
75
- return this._threshold;
76
- }
77
- set threshold(value) {
78
- this._threshold = Math.max(-60, Math.min(0, value));
79
- if (this._setup) this._setup.compressor.threshold.setTargetAtTime(this._threshold, this._setup.compressor.context.currentTime, .01);
80
- }
81
- /**
82
- * Attack time in seconds for the limiter to engage. Range 0..1, default 0.003.
83
- * Changes are ramped smoothly via `setTargetAtTime`.
84
- */
85
- get attack() {
86
- return this._attack;
87
- }
88
- set attack(value) {
89
- this._attack = Math.max(0, Math.min(1, value));
90
- if (this._setup) this._setup.compressor.attack.setTargetAtTime(this._attack, this._setup.compressor.context.currentTime, .01);
91
- }
92
- /**
93
- * Release time in seconds for the limiter to disengage. Range 0..1, default 0.25.
94
- * Changes are ramped smoothly via `setTargetAtTime`.
95
- */
96
- get release() {
97
- return this._release;
98
- }
99
- set release(value) {
100
- this._release = Math.max(0, Math.min(1, value));
101
- if (this._setup) this._setup.compressor.release.setTargetAtTime(this._release, this._setup.compressor.context.currentTime, .01);
102
- }
103
- /**
104
- * Input-to-output dB ratio above the threshold. Range 1..20, default 20
105
- * (brick-wall). Lower for a softer, more compressor-like limiter.
106
- * Changes are ramped smoothly via `setTargetAtTime`.
107
- */
108
- get ratio() {
109
- return this._ratio;
110
- }
111
- set ratio(value) {
112
- this._ratio = Math.max(1, Math.min(20, value));
113
- if (this._setup) this._setup.compressor.ratio.setTargetAtTime(this._ratio, this._setup.compressor.context.currentTime, .01);
114
- }
115
- /**
116
- * Width in dB of the transition region around the threshold (soft knee).
117
- * Range 0..40, default 0 (hard knee). Raise for a gentler transition into
118
- * limiting. Changes are ramped smoothly via `setTargetAtTime`.
119
- */
120
- get knee() {
121
- return this._knee;
122
- }
123
- set knee(value) {
124
- this._knee = Math.max(0, Math.min(40, value));
125
- if (this._setup) this._setup.compressor.knee.setTargetAtTime(this._knee, this._setup.compressor.context.currentTime, .01);
126
- }
127
- /**
128
- * Dry/wet mix level, 0..1. The dry level is automatically `1 - wet`.
129
- * Changes are ramped smoothly via `setTargetAtTime`. Default 1.0.
130
- */
131
- get wet() {
132
- return this._wet;
133
- }
134
- set wet(value) {
135
- this._wet = Math.max(0, Math.min(1, value));
136
- if (this._setup) {
137
- const ctx = this._setup.wetGain.context;
138
- this._setup.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, .01);
139
- this._setup.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, .01);
140
- }
141
- }
142
- destroy() {
143
- this._teardown();
144
- if (this._setup) {
145
- this._setup.inputGain.disconnect();
146
- this._setup.compressor.disconnect();
147
- this._setup.dryGain.disconnect();
148
- this._setup.wetGain.disconnect();
149
- this._setup.outputGain.disconnect();
150
- this._setup = null;
151
- }
152
- }
153
- _setupNodes(ctx) {
154
- const inputGain = ctx.createGain();
155
- const outputGain = ctx.createGain();
156
- const compressor = ctx.createDynamicsCompressor();
157
- const dryGain = ctx.createGain();
158
- const wetGain = ctx.createGain();
159
- inputGain.gain.setValueAtTime(1, ctx.currentTime);
160
- outputGain.gain.setValueAtTime(1, ctx.currentTime);
161
- dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);
162
- wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);
163
- compressor.ratio.setValueAtTime(this._ratio, ctx.currentTime);
164
- compressor.knee.setValueAtTime(this._knee, ctx.currentTime);
165
- compressor.threshold.setValueAtTime(this._threshold, ctx.currentTime);
166
- compressor.attack.setValueAtTime(this._attack, ctx.currentTime);
167
- compressor.release.setValueAtTime(this._release, ctx.currentTime);
168
- inputGain.connect(dryGain);
169
- dryGain.connect(outputGain);
170
- inputGain.connect(compressor);
171
- compressor.connect(wetGain);
172
- wetGain.connect(outputGain);
173
- this._setup = {
174
- inputGain,
175
- outputGain,
176
- compressor,
177
- dryGain,
178
- wetGain
179
- };
180
- }
181
- };
182
-
183
- //#endregion
184
- export { LimiterEffect };
185
- //# sourceMappingURL=LimiterEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LimiterEffect.js","names":[],"sources":["../../../src/effects/LimiterEffect.ts"],"sourcesContent":["import { AudioEffect } from '@codexo/exojs';\n\n/** Construction options for {@link LimiterEffect}. */\nexport interface LimiterEffectOptions {\n /**\n * Threshold in dBFS above which limiting is applied. Range −60..0, default −3.\n */\n threshold?: number;\n /**\n * Time in seconds for the limiter to engage after the signal exceeds the\n * threshold. Range 0..1, default 0.003.\n */\n attack?: number;\n /**\n * Time in seconds for the limiter to release after the signal drops below the\n * threshold. Range 0..1, default 0.25.\n */\n release?: number;\n /**\n * Dry/wet mix, 0..1. The dry level is automatically `1 - wet`. Default 1.0.\n * A limiter is typically used fully wet, but exposing this allows parallel\n * processing workflows.\n */\n wet?: number;\n /**\n * Input-to-output dB ratio above the threshold. Range 1..20, default 20, the\n * steepest a `DynamicsCompressorNode` allows. Lower it for a softer, more\n * compressor-like limiter.\n */\n ratio?: number;\n /**\n * Width in dB of the transition region around the threshold (soft knee).\n * Range 0..40, default 0 (hard knee). Raise it for a gentler transition\n * into limiting.\n */\n knee?: number;\n}\n\ninterface LimiterEffectSetup {\n readonly inputGain: GainNode;\n readonly outputGain: GainNode;\n readonly compressor: DynamicsCompressorNode;\n readonly dryGain: GainNode;\n readonly wetGain: GainNode;\n}\n\n/**\n * Limiter-style compressor backed by a Web Audio `DynamicsCompressorNode` set\n * for hard limiting: the highest ratio the node allows (20), zero knee (hard\n * knee), and a fast attack. Use it at the end of a chain to tame peaks.\n *\n * It is not a brick-wall peak limiter: the node has no lookahead, so a\n * transient faster than `attack` passes before gain reduction engages, and\n * above the threshold the level still rises by 1 dB per 20 dB of input.\n * Leave headroom below 0 dBFS rather than relying on it to stop every clip.\n *\n * The compressor `ratio` and `knee` default to the hardest values (20 and 0\n * respectively) but remain configurable, unlike a truly fixed limiter,\n * because callers occasionally want a softer, more compressor-like limiting\n * curve (lower ratio) or a gentler transition into limiting (larger knee)\n * without switching to {@link CompressorEffect} and losing the dry/wet mix.\n * The effect also exposes a dry/wet mix for API consistency and parallel\n * processing workflows, though a fully-wet signal (`wet = 1`) is the typical\n * configuration.\n *\n * Node graph:\n * ```\n * input(GainNode) → dryGain → output(GainNode)\n * input → compressor → wetGain → output\n * ```\n * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`.\n *\n * @example\n * ```ts\n * const limiter = new LimiterEffect({ threshold: -3, release: 0.1 });\n * masterBus.addEffect(limiter);\n * ```\n */\nexport class LimiterEffect extends AudioEffect {\n private _setup: LimiterEffectSetup | null = null;\n private _threshold: number;\n private _attack: number;\n private _release: number;\n private _wet: number;\n private _ratio: number;\n private _knee: number;\n\n public constructor(options: LimiterEffectOptions = {}) {\n super();\n this._threshold = Math.max(-60, Math.min(0, options.threshold ?? -3));\n this._attack = Math.max(0, Math.min(1, options.attack ?? 0.003));\n this._release = Math.max(0, Math.min(1, options.release ?? 0.25));\n this._wet = Math.max(0, Math.min(1, options.wet ?? 1));\n this._ratio = Math.max(1, Math.min(20, options.ratio ?? 20));\n this._knee = Math.max(0, Math.min(40, options.knee ?? 0));\n this._deferSetup(context => this._setupNodes(context));\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('LimiterEffect 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('LimiterEffect not yet initialized.');\n return this._setup.outputGain;\n }\n\n /**\n * Threshold in dBFS above which limiting is applied. Range −60..0, default −3.\n * Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get threshold(): number {\n return this._threshold;\n }\n\n public set threshold(value: number) {\n this._threshold = Math.max(-60, Math.min(0, value));\n if (this._setup) {\n this._setup.compressor.threshold.setTargetAtTime(this._threshold, this._setup.compressor.context.currentTime, 0.01);\n }\n }\n\n /**\n * Attack time in seconds for the limiter to engage. Range 0..1, default 0.003.\n * Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get attack(): number {\n return this._attack;\n }\n\n public set attack(value: number) {\n this._attack = Math.max(0, Math.min(1, value));\n if (this._setup) {\n this._setup.compressor.attack.setTargetAtTime(this._attack, this._setup.compressor.context.currentTime, 0.01);\n }\n }\n\n /**\n * Release time in seconds for the limiter to disengage. Range 0..1, default 0.25.\n * Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get release(): number {\n return this._release;\n }\n\n public set release(value: number) {\n this._release = Math.max(0, Math.min(1, value));\n if (this._setup) {\n this._setup.compressor.release.setTargetAtTime(this._release, this._setup.compressor.context.currentTime, 0.01);\n }\n }\n\n /**\n * Input-to-output dB ratio above the threshold. Range 1..20, default 20\n * (brick-wall). Lower for a softer, more compressor-like limiter.\n * Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get ratio(): number {\n return this._ratio;\n }\n\n public set ratio(value: number) {\n this._ratio = Math.max(1, Math.min(20, value));\n if (this._setup) {\n this._setup.compressor.ratio.setTargetAtTime(this._ratio, this._setup.compressor.context.currentTime, 0.01);\n }\n }\n\n /**\n * Width in dB of the transition region around the threshold (soft knee).\n * Range 0..40, default 0 (hard knee). Raise for a gentler transition into\n * limiting. Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get knee(): number {\n return this._knee;\n }\n\n public set knee(value: number) {\n this._knee = Math.max(0, Math.min(40, value));\n if (this._setup) {\n this._setup.compressor.knee.setTargetAtTime(this._knee, this._setup.compressor.context.currentTime, 0.01);\n }\n }\n\n /**\n * Dry/wet 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 public override destroy(): void {\n this._teardown();\n if (this._setup) {\n this._setup.inputGain.disconnect();\n this._setup.compressor.disconnect();\n this._setup.dryGain.disconnect();\n this._setup.wetGain.disconnect();\n this._setup.outputGain.disconnect();\n this._setup = null;\n }\n }\n\n private _setupNodes(ctx: AudioContext): void {\n const inputGain = ctx.createGain();\n const outputGain = ctx.createGain();\n const compressor = ctx.createDynamicsCompressor();\n const dryGain = ctx.createGain();\n const wetGain = ctx.createGain();\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 // Defaults to brick-wall behaviour (high ratio, hard knee) but both remain\n // configurable - see LimiterEffectOptions.ratio / .knee.\n compressor.ratio.setValueAtTime(this._ratio, ctx.currentTime);\n compressor.knee.setValueAtTime(this._knee, ctx.currentTime);\n compressor.threshold.setValueAtTime(this._threshold, ctx.currentTime);\n compressor.attack.setValueAtTime(this._attack, ctx.currentTime);\n compressor.release.setValueAtTime(this._release, ctx.currentTime);\n\n // Dry path: input → dryGain → output\n inputGain.connect(dryGain);\n dryGain.connect(outputGain);\n\n // Wet path: input → compressor → wetGain → output\n inputGain.connect(compressor);\n compressor.connect(wetGain);\n wetGain.connect(outputGain);\n\n this._setup = { inputGain, outputGain, compressor, dryGain, wetGain };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,IAAa,gBAAb,cAAmC,YAAY;CAC7C,AAAQ,SAAoC;CAC5C,AAAQ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aAAa,GAAI;EAC/E;CACF;CAEA,AAAgB,UAAgB;EAC9B,KAAK,UAAU;EACf,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,UAAU,WAAW;GACjC,KAAK,OAAO,WAAW,WAAW;GAClC,KAAK,OAAO,QAAQ,WAAW;GAC/B,KAAK,OAAO,QAAQ,WAAW;GAC/B,KAAK,OAAO,WAAW,WAAW;GAClC,KAAK,SAAS;EAChB;CACF;CAEA,AAAQ,YAAY,KAAyB;EAC3C,MAAM,YAAY,IAAI,WAAW;EACjC,MAAM,aAAa,IAAI,WAAW;EAClC,MAAM,aAAa,IAAI,yBAAyB;EAChD,MAAM,UAAU,IAAI,WAAW;EAC/B,MAAM,UAAU,IAAI,WAAW;EAE/B,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;EAItD,WAAW,MAAM,eAAe,KAAK,QAAQ,IAAI,WAAW;EAC5D,WAAW,KAAK,eAAe,KAAK,OAAO,IAAI,WAAW;EAC1D,WAAW,UAAU,eAAe,KAAK,YAAY,IAAI,WAAW;EACpE,WAAW,OAAO,eAAe,KAAK,SAAS,IAAI,WAAW;EAC9D,WAAW,QAAQ,eAAe,KAAK,UAAU,IAAI,WAAW;EAGhE,UAAU,QAAQ,OAAO;EACzB,QAAQ,QAAQ,UAAU;EAG1B,UAAU,QAAQ,UAAU;EAC5B,WAAW,QAAQ,OAAO;EAC1B,QAAQ,QAAQ,UAAU;EAE1B,KAAK,SAAS;GAAE;GAAW;GAAY;GAAY;GAAS;EAAQ;CACtE;AACF"}
@@ -1,126 +0,0 @@
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
- constructor(options?: PhaserEffectOptions);
77
- /**
78
- * The node where audio enters this effect. Throws if the audio context is
79
- * not yet initialized.
80
- */
81
- get inputNode(): AudioNode;
82
- /**
83
- * The node where audio exits this effect. Throws if the audio context is
84
- * not yet initialized.
85
- */
86
- get outputNode(): AudioNode;
87
- /**
88
- * Number of allpass filter stages (even integer, 2..12). Set at construction
89
- * time only; read-only at runtime.
90
- */
91
- get stages(): number;
92
- /**
93
- * LFO sweep rate in Hz. Range 0..20, default 0.5. Changes are ramped
94
- * smoothly via `setTargetAtTime`.
95
- */
96
- get rateHz(): number;
97
- set rateHz(value: number);
98
- /**
99
- * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.
100
- * Changes are ramped smoothly and update both the filter frequencies and the
101
- * absolute LFO depth.
102
- */
103
- get baseFrequency(): number;
104
- set baseFrequency(value: number);
105
- /**
106
- * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,
107
- * default 0.6. Changes are ramped smoothly via `setTargetAtTime`.
108
- */
109
- get depth(): number;
110
- set depth(value: number);
111
- /**
112
- * Feedback gain from the last stage back to the first. Range 0..0.9,
113
- * default 0.3. Changes are ramped smoothly via `setTargetAtTime`.
114
- */
115
- get feedback(): number;
116
- set feedback(value: number);
117
- /**
118
- * Wet (phased) mix level, 0..1. The dry level is automatically `1 - wet`.
119
- * Changes are ramped smoothly via `setTargetAtTime`. Default 0.5.
120
- */
121
- get wet(): number;
122
- set wet(value: number);
123
- destroy(): void;
124
- private _setupNodes;
125
- }
126
- //# sourceMappingURL=PhaserEff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B;IACD,IAAW,KAAK,CAAC,KAAK,EAAE,MAAM,EAK7B;IAED;;;OAGG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,IAAW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAKhC;IAED;;;OAGG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAO3B;IAMe,OAAO,IAAI,IAAI,CAiB9B;IAMD,OAAO,CAAC,WAAW;CA4EpB"}
@@ -1,213 +0,0 @@
1
- import { AudioEffect } from "@codexo/exojs";
2
-
3
- //#region src/effects/PhaserEffect.ts
4
- /**
5
- * Phaser effect implemented with native Web Audio nodes (no worklet required).
6
- *
7
- * The wet signal passes through a cascade of allpass `BiquadFilterNode`s whose
8
- * centre frequencies are swept synchronously by a sine LFO. The phase shift
9
- * produced by each allpass stage creates sweeping notches when summed with the
10
- * dry signal. An optional feedback path from the last stage back to the first
11
- * adds resonance and sharpens the effect.
12
- *
13
- * Node graph:
14
- * ```
15
- * inputGain ┬── dryGain ───────────────────────────────────────┐
16
- * │ ├── outputGain
17
- * └── allpass[0] ─► ... ─► allpass[N-1] ── wetGain ───┘
18
- * ▲ │
19
- * └── feedbackDelay ◄── feedbackGain ◄─────────┘
20
- *
21
- * lfoOscillator ── lfoGain (depth × baseFrequency Hz) ──► each allpass.frequency
22
- * ```
23
- * Note: `feedbackDelay` is a {@link DelayNode} with `delayTime = 0`. Even at
24
- * zero delay the node itself breaks the zero-latency cycle, which spec-compliant
25
- * browsers (Chrome, Edge, Safari) would otherwise mute entirely.
26
- * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`;
27
- * `feedbackGain.gain = feedback`; `lfoGain.gain = depth × baseFrequency`.
28
- *
29
- * @example
30
- * ```ts
31
- * const phaser = new PhaserEffect({ stages: 6, rateHz: 0.3, depth: 0.8, wet: 0.6 });
32
- * bus.addEffect(phaser);
33
- *
34
- * // Automate the rate at runtime
35
- * phaser.rateHz = 1.2;
36
- * ```
37
- */
38
- var PhaserEffect = class extends AudioEffect {
39
- _setup = null;
40
- _stages;
41
- _rateHz;
42
- _baseFrequency;
43
- _depth;
44
- _feedback;
45
- _wet;
46
- constructor(options = {}) {
47
- super();
48
- const rawStages = Math.max(2, Math.min(12, Math.round(options.stages ?? 4)));
49
- this._stages = rawStages % 2 !== 0 ? Math.min(12, rawStages + 1) : rawStages;
50
- this._rateHz = Math.max(0, Math.min(20, options.rateHz ?? .5));
51
- this._baseFrequency = Math.max(50, Math.min(5e3, options.baseFrequency ?? 500));
52
- this._depth = Math.max(0, Math.min(1, options.depth ?? .6));
53
- this._feedback = Math.max(0, Math.min(.9, options.feedback ?? .3));
54
- this._wet = Math.max(0, Math.min(1, options.wet ?? .5));
55
- this._deferSetup((context) => this._setupNodes(context));
56
- }
57
- /**
58
- * The node where audio enters this effect. Throws if the audio context is
59
- * not yet initialized.
60
- */
61
- get inputNode() {
62
- if (!this._setup) throw new Error("PhaserEffect not yet initialized.");
63
- return this._setup.inputGain;
64
- }
65
- /**
66
- * The node where audio exits this effect. Throws if the audio context is
67
- * not yet initialized.
68
- */
69
- get outputNode() {
70
- if (!this._setup) throw new Error("PhaserEffect not yet initialized.");
71
- return this._setup.outputGain;
72
- }
73
- /**
74
- * Number of allpass filter stages (even integer, 2..12). Set at construction
75
- * time only; read-only at runtime.
76
- */
77
- get stages() {
78
- return this._stages;
79
- }
80
- /**
81
- * LFO sweep rate in Hz. Range 0..20, default 0.5. Changes are ramped
82
- * smoothly via `setTargetAtTime`.
83
- */
84
- get rateHz() {
85
- return this._rateHz;
86
- }
87
- set rateHz(value) {
88
- this._rateHz = Math.max(0, Math.min(20, value));
89
- if (this._setup) this._setup.lfoOscillator.frequency.setTargetAtTime(this._rateHz, this._setup.inputGain.context.currentTime, .01);
90
- }
91
- /**
92
- * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.
93
- * Changes are ramped smoothly and update both the filter frequencies and the
94
- * absolute LFO depth.
95
- */
96
- get baseFrequency() {
97
- return this._baseFrequency;
98
- }
99
- set baseFrequency(value) {
100
- this._baseFrequency = Math.max(50, Math.min(5e3, value));
101
- if (this._setup) {
102
- const ctx = this._setup.inputGain.context;
103
- for (const filter of this._setup.allpassFilters) filter.frequency.setTargetAtTime(this._baseFrequency, ctx.currentTime, .01);
104
- this._setup.lfoGain.gain.setTargetAtTime(this._depth * this._baseFrequency, ctx.currentTime, .01);
105
- }
106
- }
107
- /**
108
- * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,
109
- * default 0.6. Changes are ramped smoothly via `setTargetAtTime`.
110
- */
111
- get depth() {
112
- return this._depth;
113
- }
114
- set depth(value) {
115
- this._depth = Math.max(0, Math.min(1, value));
116
- if (this._setup) this._setup.lfoGain.gain.setTargetAtTime(this._depth * this._baseFrequency, this._setup.inputGain.context.currentTime, .01);
117
- }
118
- /**
119
- * Feedback gain from the last stage back to the first. Range 0..0.9,
120
- * default 0.3. Changes are ramped smoothly via `setTargetAtTime`.
121
- */
122
- get feedback() {
123
- return this._feedback;
124
- }
125
- set feedback(value) {
126
- this._feedback = Math.max(0, Math.min(.9, value));
127
- if (this._setup) this._setup.feedbackGain.gain.setTargetAtTime(this._feedback, this._setup.inputGain.context.currentTime, .01);
128
- }
129
- /**
130
- * Wet (phased) mix level, 0..1. The dry level is automatically `1 - wet`.
131
- * Changes are ramped smoothly via `setTargetAtTime`. Default 0.5.
132
- */
133
- get wet() {
134
- return this._wet;
135
- }
136
- set wet(value) {
137
- this._wet = Math.max(0, Math.min(1, value));
138
- if (this._setup) {
139
- const ctx = this._setup.wetGain.context;
140
- this._setup.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, .01);
141
- this._setup.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, .01);
142
- }
143
- }
144
- destroy() {
145
- this._teardown();
146
- if (this._setup) {
147
- this._setup.lfoOscillator.stop();
148
- this._setup.lfoOscillator.disconnect();
149
- this._setup.lfoGain.disconnect();
150
- for (const filter of this._setup.allpassFilters) filter.disconnect();
151
- this._setup.feedbackGain.disconnect();
152
- this._setup.feedbackDelay.disconnect();
153
- this._setup.dryGain.disconnect();
154
- this._setup.wetGain.disconnect();
155
- this._setup.inputGain.disconnect();
156
- this._setup.outputGain.disconnect();
157
- this._setup = null;
158
- }
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 feedbackGain = ctx.createGain();
166
- const lfoGain = ctx.createGain();
167
- const feedbackDelay = ctx.createDelay(1);
168
- feedbackDelay.delayTime.setValueAtTime(0, ctx.currentTime);
169
- inputGain.gain.setValueAtTime(1, ctx.currentTime);
170
- outputGain.gain.setValueAtTime(1, ctx.currentTime);
171
- dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);
172
- wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);
173
- feedbackGain.gain.setValueAtTime(this._feedback, ctx.currentTime);
174
- lfoGain.gain.setValueAtTime(this._depth * this._baseFrequency, ctx.currentTime);
175
- const allpassFilters = [];
176
- for (let i = 0; i < this._stages; i++) {
177
- const filter = ctx.createBiquadFilter();
178
- filter.type = "allpass";
179
- filter.frequency.setValueAtTime(this._baseFrequency, ctx.currentTime);
180
- allpassFilters.push(filter);
181
- }
182
- const lfoOscillator = ctx.createOscillator();
183
- lfoOscillator.type = "sine";
184
- lfoOscillator.frequency.value = this._rateHz;
185
- lfoOscillator.connect(lfoGain);
186
- for (const filter of allpassFilters) lfoGain.connect(filter.frequency);
187
- inputGain.connect(dryGain);
188
- dryGain.connect(outputGain);
189
- inputGain.connect(allpassFilters[0]);
190
- for (let i = 0; i < allpassFilters.length - 1; i++) allpassFilters[i].connect(allpassFilters[i + 1]);
191
- allpassFilters[allpassFilters.length - 1].connect(wetGain);
192
- wetGain.connect(outputGain);
193
- allpassFilters[allpassFilters.length - 1].connect(feedbackGain);
194
- feedbackGain.connect(feedbackDelay);
195
- feedbackDelay.connect(allpassFilters[0]);
196
- lfoOscillator.start();
197
- this._setup = {
198
- inputGain,
199
- outputGain,
200
- dryGain,
201
- wetGain,
202
- feedbackGain,
203
- feedbackDelay,
204
- lfoGain,
205
- allpassFilters,
206
- lfoOscillator
207
- };
208
- }
209
- };
210
-
211
- //#endregion
212
- export { PhaserEffect };
213
- //# sourceMappingURL=PhaserEffect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PhaserEffect.js","names":[],"sources":["../../../src/effects/PhaserEffect.ts"],"sourcesContent":["import { AudioEffect } from '@codexo/exojs';\n\n/** Construction options for {@link PhaserEffect}. */\nexport interface PhaserEffectOptions {\n /**\n * Number of allpass filter stages. Must be an even integer in the range\n * 2..12. Odd values are rounded up to the next even number. Default 4.\n */\n stages?: number;\n /**\n * LFO sweep rate in Hz. Range 0..20, default 0.5.\n */\n rateHz?: number;\n /**\n * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.\n */\n baseFrequency?: number;\n /**\n * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,\n * default 0.6. The LFO peak deviation equals `depth × baseFrequency` Hz,\n * so the filter frequencies sweep between\n * `baseFrequency ± depth × baseFrequency`.\n */\n depth?: number;\n /**\n * Feedback gain from the last stage back to the first stage. Range 0..0.9,\n * default 0.3. Higher values add resonance and sharpen the notch sweep.\n */\n feedback?: number;\n /**\n * Dry/wet mix, 0..1. The dry level is automatically `1 - wet`. Default 0.5.\n */\n wet?: number;\n}\n\ninterface PhaserEffectSetup {\n readonly inputGain: GainNode;\n readonly outputGain: GainNode;\n readonly dryGain: GainNode;\n readonly wetGain: GainNode;\n readonly feedbackGain: GainNode;\n readonly feedbackDelay: DelayNode;\n readonly lfoGain: GainNode;\n readonly allpassFilters: BiquadFilterNode[];\n readonly lfoOscillator: OscillatorNode;\n}\n\n/**\n * Phaser effect implemented with native Web Audio nodes (no worklet required).\n *\n * The wet signal passes through a cascade of allpass `BiquadFilterNode`s whose\n * centre frequencies are swept synchronously by a sine LFO. The phase shift\n * produced by each allpass stage creates sweeping notches when summed with the\n * dry signal. An optional feedback path from the last stage back to the first\n * adds resonance and sharpens the effect.\n *\n * Node graph:\n * ```\n * inputGain ┬── dryGain ───────────────────────────────────────┐\n * │ ├── outputGain\n * └── allpass[0] ─► ... ─► allpass[N-1] ── wetGain ───┘\n * ▲ │\n * └── feedbackDelay ◄── feedbackGain ◄─────────┘\n *\n * lfoOscillator ── lfoGain (depth × baseFrequency Hz) ──► each allpass.frequency\n * ```\n * Note: `feedbackDelay` is a {@link DelayNode} with `delayTime = 0`. Even at\n * zero delay the node itself breaks the zero-latency cycle, which spec-compliant\n * browsers (Chrome, Edge, Safari) would otherwise mute entirely.\n * Gains: `dryGain.gain = 1 - wet`; `wetGain.gain = wet`;\n * `feedbackGain.gain = feedback`; `lfoGain.gain = depth × baseFrequency`.\n *\n * @example\n * ```ts\n * const phaser = new PhaserEffect({ stages: 6, rateHz: 0.3, depth: 0.8, wet: 0.6 });\n * bus.addEffect(phaser);\n *\n * // Automate the rate at runtime\n * phaser.rateHz = 1.2;\n * ```\n */\nexport class PhaserEffect extends AudioEffect {\n private _setup: PhaserEffectSetup | null = null;\n private _stages: number;\n private _rateHz: number;\n private _baseFrequency: number;\n private _depth: number;\n private _feedback: number;\n private _wet: number;\n\n public constructor(options: PhaserEffectOptions = {}) {\n super();\n const rawStages = Math.max(2, Math.min(12, Math.round(options.stages ?? 4)));\n this._stages = rawStages % 2 !== 0 ? Math.min(12, rawStages + 1) : rawStages;\n this._rateHz = Math.max(0, Math.min(20, options.rateHz ?? 0.5));\n this._baseFrequency = Math.max(50, Math.min(5000, options.baseFrequency ?? 500));\n this._depth = Math.max(0, Math.min(1, options.depth ?? 0.6));\n this._feedback = Math.max(0, Math.min(0.9, options.feedback ?? 0.3));\n this._wet = Math.max(0, Math.min(1, options.wet ?? 0.5));\n this._deferSetup(context => this._setupNodes(context));\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('PhaserEffect 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('PhaserEffect not yet initialized.');\n return this._setup.outputGain;\n }\n\n // ---------------------------------------------------------------------------\n // Getters / setters\n // ---------------------------------------------------------------------------\n\n /**\n * Number of allpass filter stages (even integer, 2..12). Set at construction\n * time only; read-only at runtime.\n */\n public get stages(): number {\n return this._stages;\n }\n\n /**\n * LFO sweep rate in Hz. Range 0..20, default 0.5. Changes are ramped\n * smoothly via `setTargetAtTime`.\n */\n public get rateHz(): number {\n return this._rateHz;\n }\n public set rateHz(value: number) {\n this._rateHz = Math.max(0, Math.min(20, value));\n if (this._setup) {\n this._setup.lfoOscillator.frequency.setTargetAtTime(this._rateHz, this._setup.inputGain.context.currentTime, 0.01);\n }\n }\n\n /**\n * Centre frequency of all allpass stages in Hz. Range 50..5000, default 500.\n * Changes are ramped smoothly and update both the filter frequencies and the\n * absolute LFO depth.\n */\n public get baseFrequency(): number {\n return this._baseFrequency;\n }\n public set baseFrequency(value: number) {\n this._baseFrequency = Math.max(50, Math.min(5000, value));\n if (this._setup) {\n const ctx = this._setup.inputGain.context;\n for (const filter of this._setup.allpassFilters) {\n filter.frequency.setTargetAtTime(this._baseFrequency, ctx.currentTime, 0.01);\n }\n this._setup.lfoGain.gain.setTargetAtTime(this._depth * this._baseFrequency, ctx.currentTime, 0.01);\n }\n }\n\n /**\n * LFO modulation depth as a fraction of `baseFrequency`. Range 0..1,\n * default 0.6. Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get depth(): number {\n return this._depth;\n }\n public set depth(value: number) {\n this._depth = Math.max(0, Math.min(1, value));\n if (this._setup) {\n this._setup.lfoGain.gain.setTargetAtTime(this._depth * this._baseFrequency, this._setup.inputGain.context.currentTime, 0.01);\n }\n }\n\n /**\n * Feedback gain from the last stage back to the first. Range 0..0.9,\n * default 0.3. Changes are ramped smoothly via `setTargetAtTime`.\n */\n public get feedback(): number {\n return this._feedback;\n }\n public set feedback(value: number) {\n this._feedback = Math.max(0, Math.min(0.9, value));\n if (this._setup) {\n this._setup.feedbackGain.gain.setTargetAtTime(this._feedback, this._setup.inputGain.context.currentTime, 0.01);\n }\n }\n\n /**\n * Wet (phased) mix level, 0..1. The dry level is automatically `1 - wet`.\n * Changes are ramped smoothly via `setTargetAtTime`. Default 0.5.\n */\n public get wet(): number {\n return this._wet;\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 // Lifecycle\n // ---------------------------------------------------------------------------\n\n public override destroy(): void {\n this._teardown();\n if (this._setup) {\n this._setup.lfoOscillator.stop();\n this._setup.lfoOscillator.disconnect();\n this._setup.lfoGain.disconnect();\n for (const filter of this._setup.allpassFilters) {\n filter.disconnect();\n }\n this._setup.feedbackGain.disconnect();\n this._setup.feedbackDelay.disconnect();\n this._setup.dryGain.disconnect();\n this._setup.wetGain.disconnect();\n this._setup.inputGain.disconnect();\n this._setup.outputGain.disconnect();\n this._setup = null;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Private\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 feedbackGain = ctx.createGain();\n const lfoGain = ctx.createGain();\n\n // A zero-length DelayNode in the feedback path is required so that\n // spec-compliant browsers do not mute the entire allpass chain. Browsers\n // are permitted to silence feedback cycles that contain no DelayNode (i.e.\n // zero-latency cycles), so even delayTime=0 here is sufficient to make the\n // cycle legal - the DelayNode itself introduces at least one render-quantum\n // of delay regardless of its delayTime parameter.\n const feedbackDelay = ctx.createDelay(1);\n feedbackDelay.delayTime.setValueAtTime(0, ctx.currentTime);\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 feedbackGain.gain.setValueAtTime(this._feedback, ctx.currentTime);\n lfoGain.gain.setValueAtTime(this._depth * this._baseFrequency, ctx.currentTime);\n\n // Allpass filter cascade\n const allpassFilters: BiquadFilterNode[] = [];\n for (let i = 0; i < this._stages; i++) {\n const filter = ctx.createBiquadFilter();\n filter.type = 'allpass';\n filter.frequency.setValueAtTime(this._baseFrequency, ctx.currentTime);\n allpassFilters.push(filter);\n }\n\n // LFO oscillator\n const lfoOscillator = ctx.createOscillator();\n lfoOscillator.type = 'sine';\n lfoOscillator.frequency.value = this._rateHz;\n\n // LFO wiring: lfoOscillator → lfoGain → each allpass.frequency (AudioParam)\n lfoOscillator.connect(lfoGain);\n for (const filter of allpassFilters) {\n lfoGain.connect(filter.frequency as unknown as AudioNode);\n }\n\n // Dry path: inputGain → dryGain → outputGain\n inputGain.connect(dryGain);\n dryGain.connect(outputGain);\n\n // Wet path: inputGain → allpass[0] → ... → allpass[N-1] → wetGain → outputGain\n inputGain.connect(allpassFilters[0]!);\n for (let i = 0; i < allpassFilters.length - 1; i++) {\n allpassFilters[i]!.connect(allpassFilters[i + 1]!);\n }\n allpassFilters[allpassFilters.length - 1]!.connect(wetGain);\n wetGain.connect(outputGain);\n\n // Feedback path: allpass[N-1] → feedbackGain → feedbackDelay → allpass[0]\n // feedbackDelay breaks the zero-latency cycle so browsers do not mute the chain.\n allpassFilters[allpassFilters.length - 1]!.connect(feedbackGain);\n feedbackGain.connect(feedbackDelay);\n feedbackDelay.connect(allpassFilters[0]!);\n\n lfoOscillator.start();\n\n this._setup = {\n inputGain,\n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AW;EAChE,QAAQ,KAAK,eAAe,KAAK,SAAS,KAAK,gBAAgB,IAAI,WAAW;EAG9E,MAAM,iBAAqC,CAAC;EAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,SAAS,KAAK;GACrC,MAAM,SAAS,IAAI,mBAAmB;GACtC,OAAO,OAAO;GACd,OAAO,UAAU,eAAe,KAAK,gBAAgB,IAAI,WAAW;GACpE,eAAe,KAAK,MAAM;EAC5B;EAGA,MAAM,gBAAgB,IAAI,iBAAiB;EAC3C,cAAc,OAAO;EACrB,cAAc,UAAU,QAAQ,KAAK;EAGrC,cAAc,QAAQ,OAAO;EAC7B,KAAK,MAAM,UAAU,gBACnB,QAAQ,QAAQ,OAAO,SAAiC;EAI1D,UAAU,QAAQ,OAAO;EACzB,QAAQ,QAAQ,UAAU;EAG1B,UAAU,QAAQ,eAAe,EAAG;EACpC,KAAK,IAAI,IAAI,GAAG,IAAI,eAAe,SAAS,GAAG,KAC7C,eAAe,EAAE,CAAE,QAAQ,eAAe,IAAI,EAAG;EAEnD,eAAe,eAAe,SAAS,EAAE,CAAE,QAAQ,OAAO;EAC1D,QAAQ,QAAQ,UAAU;EAI1B,eAAe,eAAe,SAAS,EAAE,CAAE,QAAQ,YAAY;EAC/D,aAAa,QAAQ,aAAa;EAClC,cAAc,QAAQ,eAAe,EAAG;EAExC,cAAc,MAAM;EAEpB,KAAK,SAAS;GACZ;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;CACF;AACF"}
@@ -1,83 +0,0 @@
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
- constructor(options?: PingPongDelayEffectOptions);
49
- /**
50
- * The node where audio enters this effect. Throws if the audio context is
51
- * not yet initialized.
52
- */
53
- get inputNode(): AudioNode;
54
- /**
55
- * The node where audio exits this effect. Throws if the audio context is
56
- * not yet initialized.
57
- */
58
- get outputNode(): AudioNode;
59
- /**
60
- * Delay time per tap in seconds. Both the left and right delay nodes share
61
- * the same delay time. Range 0.01..2, default 0.25.
62
- * Changes are ramped smoothly via `setTargetAtTime`.
63
- */
64
- get delayTime(): number;
65
- set delayTime(value: number);
66
- /**
67
- * Cross-channel feedback fraction. Each delayed tap feeds this fraction of
68
- * its signal into the opposite channel's delay, sustaining the L↔R bounce.
69
- * Range 0..0.9, default 0.4. Changes are ramped smoothly via
70
- * `setTargetAtTime`.
71
- */
72
- get feedback(): number;
73
- set feedback(value: number);
74
- /**
75
- * Wet (ping-pong) mix level, 0..1. The dry level is automatically `1 - wet`.
76
- * Changes are ramped smoothly via `setTargetAtTime`. Default 0.4.
77
- */
78
- get wet(): number;
79
- set wet(value: number);
80
- destroy(): void;
81
- private _setupNodes;
82
- }
83
- //# sourceMappingURL=PingPongDelayEffect.d.ts.map