@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.
Files changed (114) hide show
  1. package/dist/esm/AudioAnalyser.d.ts +4 -3
  2. package/dist/esm/AudioAnalyser.d.ts.map +1 -0
  3. package/dist/esm/AudioAnalyser.js +365 -468
  4. package/dist/esm/AudioAnalyser.js.map +1 -1
  5. package/dist/esm/BeatDetector.d.ts +16 -15
  6. package/dist/esm/BeatDetector.d.ts.map +1 -0
  7. package/dist/esm/BeatDetector.js +370 -428
  8. package/dist/esm/BeatDetector.js.map +1 -1
  9. package/dist/esm/dsp/fft.d.ts +5 -5
  10. package/dist/esm/dsp/fft.d.ts.map +1 -0
  11. package/dist/esm/dsp/mel.d.ts +6 -6
  12. package/dist/esm/dsp/mel.d.ts.map +1 -0
  13. package/dist/esm/dsp/mel.js +55 -64
  14. package/dist/esm/dsp/mel.js.map +1 -1
  15. package/dist/esm/dsp/tempogram.d.ts +60 -20
  16. package/dist/esm/dsp/tempogram.d.ts.map +1 -0
  17. package/dist/esm/effects/AutoWahEffect.d.ts +3 -2
  18. package/dist/esm/effects/AutoWahEffect.d.ts.map +1 -0
  19. package/dist/esm/effects/AutoWahEffect.js +210 -237
  20. package/dist/esm/effects/AutoWahEffect.js.map +1 -1
  21. package/dist/esm/effects/BitCrusherEffect.d.ts +3 -2
  22. package/dist/esm/effects/BitCrusherEffect.d.ts.map +1 -0
  23. package/dist/esm/effects/BitCrusherEffect.js +72 -70
  24. package/dist/esm/effects/BitCrusherEffect.js.map +1 -1
  25. package/dist/esm/effects/ChorusEffect.d.ts +2 -1
  26. package/dist/esm/effects/ChorusEffect.d.ts.map +1 -0
  27. package/dist/esm/effects/ChorusEffect.js +132 -150
  28. package/dist/esm/effects/ChorusEffect.js.map +1 -1
  29. package/dist/esm/effects/CompressorEffect.d.ts +2 -1
  30. package/dist/esm/effects/CompressorEffect.d.ts.map +1 -0
  31. package/dist/esm/effects/CompressorEffect.js +104 -118
  32. package/dist/esm/effects/CompressorEffect.js.map +1 -1
  33. package/dist/esm/effects/ConvolutionEffect.d.ts +10 -5
  34. package/dist/esm/effects/ConvolutionEffect.d.ts.map +1 -0
  35. package/dist/esm/effects/ConvolutionEffect.js +208 -189
  36. package/dist/esm/effects/ConvolutionEffect.js.map +1 -1
  37. package/dist/esm/effects/DelayEffect.d.ts +1 -0
  38. package/dist/esm/effects/DelayEffect.d.ts.map +1 -0
  39. package/dist/esm/effects/DelayEffect.js +105 -109
  40. package/dist/esm/effects/DelayEffect.js.map +1 -1
  41. package/dist/esm/effects/DistortionEffect.d.ts +4 -3
  42. package/dist/esm/effects/DistortionEffect.d.ts.map +1 -0
  43. package/dist/esm/effects/DistortionEffect.js +190 -195
  44. package/dist/esm/effects/DistortionEffect.js.map +1 -1
  45. package/dist/esm/effects/DuckingEffect.d.ts +3 -2
  46. package/dist/esm/effects/DuckingEffect.d.ts.map +1 -0
  47. package/dist/esm/effects/DuckingEffect.js +91 -172
  48. package/dist/esm/effects/DuckingEffect.js.map +1 -1
  49. package/dist/esm/effects/EqualizerEffect.d.ts +1 -0
  50. package/dist/esm/effects/EqualizerEffect.d.ts.map +1 -0
  51. package/dist/esm/effects/EqualizerEffect.js +120 -133
  52. package/dist/esm/effects/EqualizerEffect.js.map +1 -1
  53. package/dist/esm/effects/FlangerEffect.d.ts +7 -6
  54. package/dist/esm/effects/FlangerEffect.d.ts.map +1 -0
  55. package/dist/esm/effects/FlangerEffect.js +172 -201
  56. package/dist/esm/effects/FlangerEffect.js.map +1 -1
  57. package/dist/esm/effects/GranularEffect.d.ts +3 -2
  58. package/dist/esm/effects/GranularEffect.d.ts.map +1 -0
  59. package/dist/esm/effects/GranularEffect.js +100 -95
  60. package/dist/esm/effects/GranularEffect.js.map +1 -1
  61. package/dist/esm/effects/LimiterEffect.d.ts +1 -0
  62. package/dist/esm/effects/LimiterEffect.d.ts.map +1 -0
  63. package/dist/esm/effects/LimiterEffect.js +182 -194
  64. package/dist/esm/effects/LimiterEffect.js.map +1 -1
  65. package/dist/esm/effects/PhaserEffect.d.ts +2 -1
  66. package/dist/esm/effects/PhaserEffect.d.ts.map +1 -0
  67. package/dist/esm/effects/PhaserEffect.js +214 -254
  68. package/dist/esm/effects/PhaserEffect.js.map +1 -1
  69. package/dist/esm/effects/PingPongDelayEffect.d.ts +2 -1
  70. package/dist/esm/effects/PingPongDelayEffect.d.ts.map +1 -0
  71. package/dist/esm/effects/PingPongDelayEffect.js +172 -185
  72. package/dist/esm/effects/PingPongDelayEffect.js.map +1 -1
  73. package/dist/esm/effects/PitchShiftEffect.d.ts +3 -2
  74. package/dist/esm/effects/PitchShiftEffect.d.ts.map +1 -0
  75. package/dist/esm/effects/PitchShiftEffect.js +60 -60
  76. package/dist/esm/effects/PitchShiftEffect.js.map +1 -1
  77. package/dist/esm/effects/ReverbEffect.d.ts +2 -1
  78. package/dist/esm/effects/ReverbEffect.d.ts.map +1 -0
  79. package/dist/esm/effects/ReverbEffect.js +113 -117
  80. package/dist/esm/effects/ReverbEffect.js.map +1 -1
  81. package/dist/esm/effects/RingModulatorEffect.d.ts +4 -3
  82. package/dist/esm/effects/RingModulatorEffect.d.ts.map +1 -0
  83. package/dist/esm/effects/RingModulatorEffect.js +153 -161
  84. package/dist/esm/effects/RingModulatorEffect.js.map +1 -1
  85. package/dist/esm/effects/TremoloEffect.d.ts +1 -0
  86. package/dist/esm/effects/TremoloEffect.d.ts.map +1 -0
  87. package/dist/esm/effects/TremoloEffect.js +193 -201
  88. package/dist/esm/effects/TremoloEffect.js.map +1 -1
  89. package/dist/esm/effects/VocoderEffect.d.ts +2 -1
  90. package/dist/esm/effects/VocoderEffect.d.ts.map +1 -0
  91. package/dist/esm/effects/VocoderEffect.js +69 -80
  92. package/dist/esm/effects/VocoderEffect.js.map +1 -1
  93. package/dist/esm/index.d.ts +2 -1
  94. package/dist/esm/index.d.ts.map +1 -0
  95. package/dist/esm/index.js +23 -22
  96. package/dist/esm/worklets/beat-detector.worklet.js +5 -1162
  97. package/dist/esm/worklets/beat-detector.worklet.js.map +1 -1
  98. package/dist/esm/worklets/bit-crusher.worklet.js +5 -44
  99. package/dist/esm/worklets/bit-crusher.worklet.js.map +1 -1
  100. package/dist/esm/worklets/ducking.worklet.js +6 -0
  101. package/dist/esm/worklets/ducking.worklet.js.map +1 -0
  102. package/dist/esm/worklets/granular.worklet.js +5 -97
  103. package/dist/esm/worklets/granular.worklet.js.map +1 -1
  104. package/dist/esm/worklets/pitch-shift.worklet.js +5 -128
  105. package/dist/esm/worklets/pitch-shift.worklet.js.map +1 -1
  106. package/dist/esm/worklets/vocoder.worklet.js +5 -93
  107. package/dist/esm/worklets/vocoder.worklet.js.map +1 -1
  108. package/package.json +6 -6
  109. package/dist/esm/index.js.map +0 -1
  110. package/dist/esm/worklets/beat-detector.worklet.d.ts +0 -1
  111. package/dist/esm/worklets/bit-crusher.worklet.d.ts +0 -1
  112. package/dist/esm/worklets/granular.worklet.d.ts +0 -1
  113. package/dist/esm/worklets/pitch-shift.worklet.d.ts +0 -1
  114. package/dist/esm/worklets/vocoder.worklet.d.ts +0 -1
@@ -1,122 +1,108 @@
1
- import { AudioEffect, onAudioContextReady, isAudioContextReady, getAudioContext } from '@codexo/exojs';
1
+ import { AudioEffect, getAudioContext, isAudioContextReady, onAudioContextReady } from "@codexo/exojs";
2
2
 
3
+ //#region src/effects/CompressorEffect.ts
3
4
  /**
4
- * Dynamic-range compressor backed by a Web Audio `DynamicsCompressorNode`.
5
- * Reduces the volume of loud signals above a threshold, evening out the
6
- * perceived loudness of a mix. All parameter changes are applied with a short
7
- * smoothing ramp so they are artifact-free during playback.
8
- */
9
- class CompressorEffect extends AudioEffect {
10
- _node = null;
11
- _threshold;
12
- _onAudioContextReady = (ctx) => {
13
- onAudioContextReady.remove(this._onAudioContextReady);
14
- this._setup(ctx);
15
- };
16
- _knee;
17
- _ratio;
18
- _attack;
19
- _release;
20
- constructor(options = {}) {
21
- super();
22
- this._threshold = Math.max(-100, Math.min(0, options.threshold ?? -24));
23
- this._knee = Math.max(0, Math.min(40, options.knee ?? 30));
24
- this._ratio = Math.max(1, Math.min(20, options.ratio ?? 12));
25
- this._attack = Math.max(0, Math.min(1, options.attack ?? 0.003));
26
- this._release = Math.max(0, Math.min(1, options.release ?? 0.25));
27
- if (isAudioContextReady()) {
28
- this._setup(getAudioContext());
29
- }
30
- else {
31
- onAudioContextReady.add(this._onAudioContextReady);
32
- }
33
- }
34
- get inputNode() {
35
- if (!this._node)
36
- throw new Error('CompressorEffect not yet initialized.');
37
- return this._node;
38
- }
39
- get outputNode() {
40
- if (!this._node)
41
- throw new Error('CompressorEffect not yet initialized.');
42
- return this._node;
43
- }
44
- /** Level above which compression begins, in dBFS. Range −100..0, default −24. */
45
- get threshold() {
46
- return this._threshold;
47
- }
48
- set threshold(value) {
49
- this._threshold = Math.max(-100, Math.min(0, value));
50
- if (this._node) {
51
- this._node.threshold.setTargetAtTime(this._threshold, this._node.context.currentTime, 0.01);
52
- }
53
- }
54
- /** Width in dB of the transition region around the threshold (soft knee). Range 0..40, default 30. */
55
- get knee() {
56
- return this._knee;
57
- }
58
- set knee(value) {
59
- this._knee = Math.max(0, Math.min(40, value));
60
- if (this._node) {
61
- this._node.knee.setTargetAtTime(this._knee, this._node.context.currentTime, 0.01);
62
- }
63
- }
64
- /** Input-to-output dB ratio above the threshold. Range 1..20, default 12. */
65
- get ratio() {
66
- return this._ratio;
67
- }
68
- set ratio(value) {
69
- this._ratio = Math.max(1, Math.min(20, value));
70
- if (this._node) {
71
- this._node.ratio.setTargetAtTime(this._ratio, this._node.context.currentTime, 0.01);
72
- }
73
- }
74
- /** Time in seconds for the compressor to engage after the signal exceeds the threshold. Range 0..1, default 0.003. */
75
- get attack() {
76
- return this._attack;
77
- }
78
- set attack(value) {
79
- this._attack = Math.max(0, Math.min(1, value));
80
- if (this._node) {
81
- this._node.attack.setTargetAtTime(this._attack, this._node.context.currentTime, 0.01);
82
- }
83
- }
84
- /** Time in seconds for the compressor to disengage after the signal drops below the threshold. Range 0..1, default 0.25. */
85
- get release() {
86
- return this._release;
87
- }
88
- set release(value) {
89
- this._release = Math.max(0, Math.min(1, value));
90
- if (this._node) {
91
- this._node.release.setTargetAtTime(this._release, this._node.context.currentTime, 0.01);
92
- }
93
- }
94
- /**
95
- * Live gain reduction in dB applied by the compressor right now. Always
96
- * `<= 0` (or `0` when the compressor isn't engaging). Read-only — drive
97
- * input level meters / sidechain visualisations off this value.
98
- *
99
- * Returns `0` until the underlying node has been created (before the
100
- * audio context is ready).
101
- */
102
- get reduction() {
103
- return this._node?.reduction ?? 0;
104
- }
105
- destroy() {
106
- onAudioContextReady.remove(this._onAudioContextReady);
107
- this._node?.disconnect();
108
- this._node = null;
109
- }
110
- _setup(ctx) {
111
- const node = ctx.createDynamicsCompressor();
112
- node.threshold.setValueAtTime(this._threshold, ctx.currentTime);
113
- node.knee.setValueAtTime(this._knee, ctx.currentTime);
114
- node.ratio.setValueAtTime(this._ratio, ctx.currentTime);
115
- node.attack.setValueAtTime(this._attack, ctx.currentTime);
116
- node.release.setValueAtTime(this._release, ctx.currentTime);
117
- this._node = node;
118
- }
119
- }
5
+ * Dynamic-range compressor backed by a Web Audio `DynamicsCompressorNode`.
6
+ * Reduces the volume of loud signals above a threshold, evening out the
7
+ * perceived loudness of a mix. All parameter changes are applied with a short
8
+ * smoothing ramp so they are artifact-free during playback.
9
+ */
10
+ var CompressorEffect = class extends AudioEffect {
11
+ _node = null;
12
+ _threshold;
13
+ _onAudioContextReady = (ctx) => {
14
+ onAudioContextReady.remove(this._onAudioContextReady);
15
+ this._setup(ctx);
16
+ };
17
+ _knee;
18
+ _ratio;
19
+ _attack;
20
+ _release;
21
+ constructor(options = {}) {
22
+ super();
23
+ this._threshold = Math.max(-100, Math.min(0, options.threshold ?? -24));
24
+ this._knee = Math.max(0, Math.min(40, options.knee ?? 30));
25
+ this._ratio = Math.max(1, Math.min(20, options.ratio ?? 12));
26
+ this._attack = Math.max(0, Math.min(1, options.attack ?? .003));
27
+ this._release = Math.max(0, Math.min(1, options.release ?? .25));
28
+ if (isAudioContextReady()) this._setup(getAudioContext());
29
+ else onAudioContextReady.add(this._onAudioContextReady);
30
+ }
31
+ get inputNode() {
32
+ if (!this._node) throw new Error("CompressorEffect not yet initialized.");
33
+ return this._node;
34
+ }
35
+ get outputNode() {
36
+ if (!this._node) throw new Error("CompressorEffect not yet initialized.");
37
+ return this._node;
38
+ }
39
+ /** Level above which compression begins, in dBFS. Range −100..0, default −24. */
40
+ get threshold() {
41
+ return this._threshold;
42
+ }
43
+ set threshold(value) {
44
+ this._threshold = Math.max(-100, Math.min(0, value));
45
+ if (this._node) this._node.threshold.setTargetAtTime(this._threshold, this._node.context.currentTime, .01);
46
+ }
47
+ /** Width in dB of the transition region around the threshold (soft knee). Range 0..40, default 30. */
48
+ get knee() {
49
+ return this._knee;
50
+ }
51
+ set knee(value) {
52
+ this._knee = Math.max(0, Math.min(40, value));
53
+ if (this._node) this._node.knee.setTargetAtTime(this._knee, this._node.context.currentTime, .01);
54
+ }
55
+ /** Input-to-output dB ratio above the threshold. Range 1..20, default 12. */
56
+ get ratio() {
57
+ return this._ratio;
58
+ }
59
+ set ratio(value) {
60
+ this._ratio = Math.max(1, Math.min(20, value));
61
+ if (this._node) this._node.ratio.setTargetAtTime(this._ratio, this._node.context.currentTime, .01);
62
+ }
63
+ /** Time in seconds for the compressor to engage after the signal exceeds the threshold. Range 0..1, default 0.003. */
64
+ get attack() {
65
+ return this._attack;
66
+ }
67
+ set attack(value) {
68
+ this._attack = Math.max(0, Math.min(1, value));
69
+ if (this._node) this._node.attack.setTargetAtTime(this._attack, this._node.context.currentTime, .01);
70
+ }
71
+ /** Time in seconds for the compressor to disengage after the signal drops below the threshold. Range 0..1, default 0.25. */
72
+ get release() {
73
+ return this._release;
74
+ }
75
+ set release(value) {
76
+ this._release = Math.max(0, Math.min(1, value));
77
+ if (this._node) this._node.release.setTargetAtTime(this._release, this._node.context.currentTime, .01);
78
+ }
79
+ /**
80
+ * Live gain reduction in dB applied by the compressor right now. Always
81
+ * `<= 0` (or `0` when the compressor isn't engaging). Read-only - drive
82
+ * input level meters / sidechain visualisations off this value.
83
+ *
84
+ * Returns `0` until the underlying node has been created (before the
85
+ * audio context is ready).
86
+ */
87
+ get reduction() {
88
+ return this._node?.reduction ?? 0;
89
+ }
90
+ destroy() {
91
+ onAudioContextReady.remove(this._onAudioContextReady);
92
+ this._node?.disconnect();
93
+ this._node = null;
94
+ }
95
+ _setup(ctx) {
96
+ const node = ctx.createDynamicsCompressor();
97
+ node.threshold.setValueAtTime(this._threshold, ctx.currentTime);
98
+ node.knee.setValueAtTime(this._knee, ctx.currentTime);
99
+ node.ratio.setValueAtTime(this._ratio, ctx.currentTime);
100
+ node.attack.setValueAtTime(this._attack, ctx.currentTime);
101
+ node.release.setValueAtTime(this._release, ctx.currentTime);
102
+ this._node = node;
103
+ }
104
+ };
120
105
 
106
+ //#endregion
121
107
  export { CompressorEffect };
122
- //# sourceMappingURL=CompressorEffect.js.map
108
+ //# sourceMappingURL=CompressorEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompressorEffect.js","sources":["../../../../src/effects/CompressorEffect.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAWA;;;;;AAKG;AACG,MAAO,gBAAiB,SAAQ,WAAW,CAAA;IACvC,KAAK,GAAkC,IAAI;AAC3C,IAAA,UAAU;AACD,IAAA,oBAAoB,GAAG,CAAC,GAAiB,KAAU;AAClE,QAAA,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;AACrD,QAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;AAClB,IAAA,CAAC;AACO,IAAA,KAAK;AACL,IAAA,MAAM;AACN,IAAA,OAAO;AACP,IAAA,QAAQ;AAEhB,IAAA,WAAA,CAAmB,UAAmC,EAAE,EAAA;AACtD,QAAA,KAAK,EAAE;QACP,IAAI,CAAC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QAAA,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,CAAC;AAC/D,QAAA,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC;AACrD,QAAA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;AACvD,QAAA,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC;AACzD,QAAA,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,WAAW,CAAC;AAC3D,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;IACnB;AACD;;;;"}
1
+ {"version":3,"file":"CompressorEffect.js","names":[],"sources":["../../../src/effects/CompressorEffect.ts"],"sourcesContent":["import { AudioEffect, getAudioContext, isAudioContextReady, onAudioContextReady } from '@codexo/exojs';\n\n/** Construction options for {@link CompressorEffect}. All values are clamped to their valid ranges on assignment. */\nexport interface CompressorEffectOptions {\n threshold?: number;\n knee?: number;\n ratio?: number;\n attack?: number;\n release?: number;\n}\n\n/**\n * Dynamic-range compressor backed by a Web Audio `DynamicsCompressorNode`.\n * Reduces the volume of loud signals above a threshold, evening out the\n * perceived loudness of a mix. All parameter changes are applied with a short\n * smoothing ramp so they are artifact-free during playback.\n */\nexport class CompressorEffect extends AudioEffect {\n private _node: DynamicsCompressorNode | null = null;\n private _threshold: number;\n private readonly _onAudioContextReady = (ctx: AudioContext): void => {\n onAudioContextReady.remove(this._onAudioContextReady);\n this._setup(ctx);\n };\n private _knee: number;\n private _ratio: number;\n private _attack: number;\n private _release: number;\n\n public constructor(options: CompressorEffectOptions = {}) {\n super();\n this._threshold = Math.max(-100, Math.min(0, options.threshold ?? -24));\n this._knee = Math.max(0, Math.min(40, options.knee ?? 30));\n this._ratio = Math.max(1, Math.min(20, options.ratio ?? 12));\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 if (isAudioContextReady()) {\n this._setup(getAudioContext());\n } else {\n onAudioContextReady.add(this._onAudioContextReady);\n }\n }\n\n public get inputNode(): AudioNode {\n if (!this._node) throw new Error('CompressorEffect not yet initialized.');\n return this._node;\n }\n\n public get outputNode(): AudioNode {\n if (!this._node) throw new Error('CompressorEffect not yet initialized.');\n return this._node;\n }\n\n /** Level above which compression begins, in dBFS. Range −100..0, default −24. */\n public get threshold(): number {\n return this._threshold;\n }\n\n public set threshold(value: number) {\n this._threshold = Math.max(-100, Math.min(0, value));\n if (this._node) {\n this._node.threshold.setTargetAtTime(this._threshold, this._node.context.currentTime, 0.01);\n }\n }\n\n /** Width in dB of the transition region around the threshold (soft knee). Range 0..40, default 30. */\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._node) {\n this._node.knee.setTargetAtTime(this._knee, this._node.context.currentTime, 0.01);\n }\n }\n\n /** Input-to-output dB ratio above the threshold. Range 1..20, default 12. */\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._node) {\n this._node.ratio.setTargetAtTime(this._ratio, this._node.context.currentTime, 0.01);\n }\n }\n\n /** Time in seconds for the compressor to engage after the signal exceeds the threshold. Range 0..1, default 0.003. */\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._node) {\n this._node.attack.setTargetAtTime(this._attack, this._node.context.currentTime, 0.01);\n }\n }\n\n /** Time in seconds for the compressor to disengage after the signal drops below the threshold. Range 0..1, default 0.25. */\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._node) {\n this._node.release.setTargetAtTime(this._release, this._node.context.currentTime, 0.01);\n }\n }\n\n /**\n * Live gain reduction in dB applied by the compressor right now. Always\n * `<= 0` (or `0` when the compressor isn't engaging). Read-only - drive\n * input level meters / sidechain visualisations off this value.\n *\n * Returns `0` until the underlying node has been created (before the\n * audio context is ready).\n */\n public get reduction(): number {\n return this._node?.reduction ?? 0;\n }\n\n public override destroy(): void {\n onAudioContextReady.remove(this._onAudioContextReady);\n this._node?.disconnect();\n this._node = null;\n }\n\n private _setup(ctx: AudioContext): void {\n const node = ctx.createDynamicsCompressor();\n node.threshold.setValueAtTime(this._threshold, ctx.currentTime);\n node.knee.setValueAtTime(this._knee, ctx.currentTime);\n node.ratio.setValueAtTime(this._ratio, ctx.currentTime);\n node.attack.setValueAtTime(this._attack, ctx.currentTime);\n node.release.setValueAtTime(this._release, ctx.currentTime);\n this._node = node;\n }\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAa,mBAAb,cAAsC,YAAY;CAChD,AAAQ,QAAuC;CAC/C,AAAQ;CACR,AAAiB,wBAAwB,QAA4B;EACnE,oBAAoB,OAAO,KAAK,oBAAoB;EACpD,KAAK,OAAO,GAAG;CACjB;CACA,AAAQ;CACR,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,AAAO,YAAY,UAAmC,CAAC,GAAG;EACxD,MAAM;EACN,KAAK,aAAa,KAAK,IAAI,MAAM,KAAK,IAAI,GAAG,QAAQ,aAAa,GAAG,CAAC;EACtE,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,QAAQ,QAAQ,EAAE,CAAC;EACzD,KAAK,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,QAAQ,SAAS,EAAE,CAAC;EAC3D,KAAK,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,UAAU,IAAK,CAAC;EAC/D,KAAK,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,QAAQ,WAAW,GAAI,CAAC;EAChE,IAAI,oBAAoB,G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B;EAC3B,OAAO,KAAK;CACd;CAEA,IAAW,QAAQ,OAAe;EAChC,KAAK,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;EAC9C,IAAI,KAAK,OACP,KAAK,MAAM,QAAQ,gBAAgB,KAAK,UAAU,KAAK,MAAM,QAAQ,aAAa,GAAI;CAE1F;;;;;;;;;CAUA,IAAW,YAAoB;EAC7B,OAAO,KAAK,OAAO,aAAa;CAClC;CAEA,AAAgB,UAAgB;EAC9B,oBAAoB,OAAO,KAAK,oBAAoB;EACpD,KAAK,OAAO,WAAW;EACvB,KAAK,QAAQ;CACf;CAEA,AAAQ,OAAO,KAAyB;EACtC,MAAM,OAAO,IAAI,yBAAyB;EAC1C,KAAK,UAAU,eAAe,KAAK,YAAY,IAAI,WAAW;EAC9D,KAAK,KAAK,eAAe,KAAK,OAAO,IAAI,WAAW;EACpD,KAAK,MAAM,eAAe,KAAK,QAAQ,IAAI,WAAW;EACtD,KAAK,OAAO,eAAe,KAAK,SAAS,IAAI,WAAW;EACxD,KAAK,QAAQ,eAAe,KAAK,UAAU,IAAI,WAAW;EAC1D,KAAK,QAAQ;CACf;AACF"}
@@ -32,7 +32,7 @@ export interface ConvolutionEffectOptions {
32
32
  /**
33
33
  * Convolution effect that convolves the input signal with a user-supplied
34
34
  * impulse response (IR). Unlike {@link ReverbEffect}, which generates a
35
- * procedural noise-based IR, `ConvolutionEffect` accepts a *real* decoded IR —
35
+ * procedural noise-based IR, `ConvolutionEffect` accepts a *real* decoded IR -
36
36
  * enabling convolution reverb from acoustic-space captures, cabinet/speaker
37
37
  * simulations, telephone/pipe character filtering, and any other linear
38
38
  * time-invariant transformation.
@@ -41,7 +41,7 @@ export interface ConvolutionEffectOptions {
41
41
  * `AudioContext.decodeAudioData`) or as a `Sound` (its `audioBuffer` is used).
42
42
  * Omitting the IR leaves `convolver.buffer` as `null`, making the wet path
43
43
  * silent and the effect act as a passthrough until {@link setImpulse} is
44
- * called — safe to add to a bus before an IR is available.
44
+ * called - safe to add to a bus before an IR is available.
45
45
  *
46
46
  * Node graph:
47
47
  * ```
@@ -52,8 +52,8 @@ export interface ConvolutionEffectOptions {
52
52
  *
53
53
  * @example
54
54
  * ```ts
55
- * await loader.load(Sound, { hall: 'hall.wav' });
56
- * const reverb = new ConvolutionEffect({ impulse: loader.get(Sound, 'hall'), wet: 0.6 });
55
+ * const hall = await loader.load(Asset.type('sound', 'hall.wav'));
56
+ * const reverb = new ConvolutionEffect({ impulse: hall, wet: 0.6 });
57
57
  * bus.addEffect(reverb);
58
58
  * ```
59
59
  */
@@ -63,6 +63,8 @@ export declare class ConvolutionEffect extends AudioEffect {
63
63
  private _normalize;
64
64
  private _gain;
65
65
  private _pendingImpulse;
66
+ /** Bumped per impulse request so a slow resample cannot overwrite a newer IR. */
67
+ private _impulseGeneration;
66
68
  private readonly _onAudioContextReady;
67
69
  constructor(options?: ConvolutionEffectOptions);
68
70
  /**
@@ -101,14 +103,17 @@ export declare class ConvolutionEffect extends AudioEffect {
101
103
  /**
102
104
  * Set or replace the impulse response. Accepts a decoded `AudioBuffer`, a
103
105
  * `Sound` (its `audioBuffer` is used), or `null` to clear the IR (wet path
104
- * goes silent). Safe to call before the audio context is ready — the impulse
106
+ * goes silent). Safe to call before the audio context is ready - the impulse
105
107
  * is stored and applied once nodes are created.
106
108
  *
107
109
  * **Web Audio note:** `normalize` is written to the convolver *before*
108
110
  * `buffer` is assigned, as required by the spec for the value to take effect.
109
111
  */
110
112
  setImpulse(ir: AudioBuffer | Sound | null): void;
113
+ /** Assign an IR that is known to match the context rate. */
114
+ private _applyImpulse;
111
115
  destroy(): void;
112
116
  private _resolveBuffer;
113
117
  private _setupNodes;
114
118
  }
119
+ //# sourceMappingURL=ConvolutionEffect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConvolutionEffect.d.ts","sourceRoot":"","sources":["../../../src/effects/ConvolutionEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,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