@codexo/exojs-audio-fx 0.15.3 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/AudioAnalyser.d.ts +4 -3
- package/dist/esm/AudioAnalyser.d.ts.map +1 -0
- package/dist/esm/AudioAnalyser.js +365 -468
- package/dist/esm/AudioAnalyser.js.map +1 -1
- package/dist/esm/BeatDetector.d.ts +16 -15
- package/dist/esm/BeatDetector.d.ts.map +1 -0
- package/dist/esm/BeatDetector.js +370 -428
- package/dist/esm/BeatDetector.js.map +1 -1
- package/dist/esm/dsp/fft.d.ts +5 -5
- package/dist/esm/dsp/fft.d.ts.map +1 -0
- package/dist/esm/dsp/mel.d.ts +6 -6
- package/dist/esm/dsp/mel.d.ts.map +1 -0
- package/dist/esm/dsp/mel.js +55 -64
- package/dist/esm/dsp/mel.js.map +1 -1
- package/dist/esm/dsp/tempogram.d.ts +60 -20
- package/dist/esm/dsp/tempogram.d.ts.map +1 -0
- package/dist/esm/effects/AutoWahEffect.d.ts +3 -2
- package/dist/esm/effects/AutoWahEffect.d.ts.map +1 -0
- package/dist/esm/effects/AutoWahEffect.js +210 -237
- package/dist/esm/effects/AutoWahEffect.js.map +1 -1
- package/dist/esm/effects/BitCrusherEffect.d.ts +3 -2
- package/dist/esm/effects/BitCrusherEffect.d.ts.map +1 -0
- package/dist/esm/effects/BitCrusherEffect.js +72 -70
- package/dist/esm/effects/BitCrusherEffect.js.map +1 -1
- package/dist/esm/effects/ChorusEffect.d.ts +2 -1
- package/dist/esm/effects/ChorusEffect.d.ts.map +1 -0
- package/dist/esm/effects/ChorusEffect.js +132 -150
- package/dist/esm/effects/ChorusEffect.js.map +1 -1
- package/dist/esm/effects/CompressorEffect.d.ts +2 -1
- package/dist/esm/effects/CompressorEffect.d.ts.map +1 -0
- package/dist/esm/effects/CompressorEffect.js +104 -118
- package/dist/esm/effects/CompressorEffect.js.map +1 -1
- package/dist/esm/effects/ConvolutionEffect.d.ts +10 -5
- package/dist/esm/effects/ConvolutionEffect.d.ts.map +1 -0
- package/dist/esm/effects/ConvolutionEffect.js +208 -189
- package/dist/esm/effects/ConvolutionEffect.js.map +1 -1
- package/dist/esm/effects/DelayEffect.d.ts +1 -0
- package/dist/esm/effects/DelayEffect.d.ts.map +1 -0
- package/dist/esm/effects/DelayEffect.js +105 -109
- package/dist/esm/effects/DelayEffect.js.map +1 -1
- package/dist/esm/effects/DistortionEffect.d.ts +4 -3
- package/dist/esm/effects/DistortionEffect.d.ts.map +1 -0
- package/dist/esm/effects/DistortionEffect.js +190 -195
- package/dist/esm/effects/DistortionEffect.js.map +1 -1
- package/dist/esm/effects/DuckingEffect.d.ts +3 -2
- package/dist/esm/effects/DuckingEffect.d.ts.map +1 -0
- package/dist/esm/effects/DuckingEffect.js +91 -172
- package/dist/esm/effects/DuckingEffect.js.map +1 -1
- package/dist/esm/effects/EqualizerEffect.d.ts +1 -0
- package/dist/esm/effects/EqualizerEffect.d.ts.map +1 -0
- package/dist/esm/effects/EqualizerEffect.js +120 -133
- package/dist/esm/effects/EqualizerEffect.js.map +1 -1
- package/dist/esm/effects/FlangerEffect.d.ts +7 -6
- package/dist/esm/effects/FlangerEffect.d.ts.map +1 -0
- package/dist/esm/effects/FlangerEffect.js +172 -201
- package/dist/esm/effects/FlangerEffect.js.map +1 -1
- package/dist/esm/effects/GranularEffect.d.ts +3 -2
- package/dist/esm/effects/GranularEffect.d.ts.map +1 -0
- package/dist/esm/effects/GranularEffect.js +100 -95
- package/dist/esm/effects/GranularEffect.js.map +1 -1
- package/dist/esm/effects/LimiterEffect.d.ts +1 -0
- package/dist/esm/effects/LimiterEffect.d.ts.map +1 -0
- package/dist/esm/effects/LimiterEffect.js +182 -194
- package/dist/esm/effects/LimiterEffect.js.map +1 -1
- package/dist/esm/effects/PhaserEffect.d.ts +2 -1
- package/dist/esm/effects/PhaserEffect.d.ts.map +1 -0
- package/dist/esm/effects/PhaserEffect.js +214 -254
- package/dist/esm/effects/PhaserEffect.js.map +1 -1
- package/dist/esm/effects/PingPongDelayEffect.d.ts +2 -1
- package/dist/esm/effects/PingPongDelayEffect.d.ts.map +1 -0
- package/dist/esm/effects/PingPongDelayEffect.js +172 -185
- package/dist/esm/effects/PingPongDelayEffect.js.map +1 -1
- package/dist/esm/effects/PitchShiftEffect.d.ts +3 -2
- package/dist/esm/effects/PitchShiftEffect.d.ts.map +1 -0
- package/dist/esm/effects/PitchShiftEffect.js +60 -60
- package/dist/esm/effects/PitchShiftEffect.js.map +1 -1
- package/dist/esm/effects/ReverbEffect.d.ts +2 -1
- package/dist/esm/effects/ReverbEffect.d.ts.map +1 -0
- package/dist/esm/effects/ReverbEffect.js +113 -117
- package/dist/esm/effects/ReverbEffect.js.map +1 -1
- package/dist/esm/effects/RingModulatorEffect.d.ts +4 -3
- package/dist/esm/effects/RingModulatorEffect.d.ts.map +1 -0
- package/dist/esm/effects/RingModulatorEffect.js +153 -161
- package/dist/esm/effects/RingModulatorEffect.js.map +1 -1
- package/dist/esm/effects/TremoloEffect.d.ts +1 -0
- package/dist/esm/effects/TremoloEffect.d.ts.map +1 -0
- package/dist/esm/effects/TremoloEffect.js +193 -201
- package/dist/esm/effects/TremoloEffect.js.map +1 -1
- package/dist/esm/effects/VocoderEffect.d.ts +2 -1
- package/dist/esm/effects/VocoderEffect.d.ts.map +1 -0
- package/dist/esm/effects/VocoderEffect.js +69 -80
- package/dist/esm/effects/VocoderEffect.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +23 -22
- package/dist/esm/worklets/beat-detector.worklet.js +5 -1162
- package/dist/esm/worklets/beat-detector.worklet.js.map +1 -1
- package/dist/esm/worklets/bit-crusher.worklet.js +5 -44
- package/dist/esm/worklets/bit-crusher.worklet.js.map +1 -1
- package/dist/esm/worklets/ducking.worklet.js +6 -0
- package/dist/esm/worklets/ducking.worklet.js.map +1 -0
- package/dist/esm/worklets/granular.worklet.js +5 -97
- package/dist/esm/worklets/granular.worklet.js.map +1 -1
- package/dist/esm/worklets/pitch-shift.worklet.js +5 -128
- package/dist/esm/worklets/pitch-shift.worklet.js.map +1 -1
- package/dist/esm/worklets/vocoder.worklet.js +5 -93
- package/dist/esm/worklets/vocoder.worklet.js.map +1 -1
- package/package.json +6 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/worklets/beat-detector.worklet.d.ts +0 -1
- package/dist/esm/worklets/bit-crusher.worklet.d.ts +0 -1
- package/dist/esm/worklets/granular.worklet.d.ts +0 -1
- package/dist/esm/worklets/pitch-shift.worklet.d.ts +0 -1
- package/dist/esm/worklets/vocoder.worklet.d.ts +0 -1
|
@@ -1,122 +1,108 @@
|
|
|
1
|
-
import { AudioEffect,
|
|
1
|
+
import { AudioEffect, getAudioContext, isAudioContextReady, onAudioContextReady } from "@codexo/exojs";
|
|
2
2
|
|
|
3
|
+
//#region src/effects/CompressorEffect.ts
|
|
3
4
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
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":["
|
|
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":"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"}
|
|
@@ -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
|
|
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(
|
|
56
|
-
* const reverb = new ConvolutionEffect({ impulse:
|
|
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
|
|
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,EAA6D,KAAK,EAAE,MAAM,eAAe,CAAC;AAE9G,0DAA0D;AAC1D,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAC9B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,eAAe,CAA6B;IAEpD,iFAAiF;IACjF,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAGnC;gBAEiB,OAAO,GAAE,wBAA6B;IAazD;;;OAGG;IACH,IAAW,SAAS,IAAI,SAAS,CAGhC;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,SAAS,CAGjC;IAED;;;OAGG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED,IAAW,GAAG,CAAC,KAAK,EAAE,MAAM,EAO3B;IAED;;;;;;;OAOG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,OAAO,EAYlC;IAED;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,IAAI,CAAC,KAAK,EAAE,MAAM,EAM5B;IAED;;;;;;;;OAQG;IACI,UAAU,CAAC,EAAE,EAAE,WAAW,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI;IA8BvD,4DAA4D;IAC5D,OAAO,CAAC,aAAa;IAUL,OAAO,IAAI,IAAI;IAY/B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,WAAW;CAkCpB"}
|