@codexo/exojs-audio-fx 0.14.0-next.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/esm/AudioAnalyser.d.ts +124 -0
  4. package/dist/esm/AudioAnalyser.js +472 -0
  5. package/dist/esm/AudioAnalyser.js.map +1 -0
  6. package/dist/esm/BeatDetector.d.ts +203 -0
  7. package/dist/esm/BeatDetector.js +422 -0
  8. package/dist/esm/BeatDetector.js.map +1 -0
  9. package/dist/esm/dsp/fft.d.ts +22 -0
  10. package/dist/esm/dsp/mel.d.ts +43 -0
  11. package/dist/esm/dsp/mel.js +70 -0
  12. package/dist/esm/dsp/mel.js.map +1 -0
  13. package/dist/esm/dsp/tempogram.d.ts +51 -0
  14. package/dist/esm/effects/ChorusEffect.d.ts +53 -0
  15. package/dist/esm/effects/ChorusEffect.js +154 -0
  16. package/dist/esm/effects/ChorusEffect.js.map +1 -0
  17. package/dist/esm/effects/CompressorEffect.d.ts +53 -0
  18. package/dist/esm/effects/CompressorEffect.js +122 -0
  19. package/dist/esm/effects/CompressorEffect.js.map +1 -0
  20. package/dist/esm/effects/DelayEffect.d.ts +35 -0
  21. package/dist/esm/effects/DelayEffect.js +113 -0
  22. package/dist/esm/effects/DelayEffect.js.map +1 -0
  23. package/dist/esm/effects/DuckingEffect.d.ts +43 -0
  24. package/dist/esm/effects/DuckingEffect.js +172 -0
  25. package/dist/esm/effects/DuckingEffect.js.map +1 -0
  26. package/dist/esm/effects/EqualizerEffect.d.ts +50 -0
  27. package/dist/esm/effects/EqualizerEffect.js +137 -0
  28. package/dist/esm/effects/EqualizerEffect.js.map +1 -0
  29. package/dist/esm/effects/GranularEffect.d.ts +62 -0
  30. package/dist/esm/effects/GranularEffect.js +107 -0
  31. package/dist/esm/effects/GranularEffect.js.map +1 -0
  32. package/dist/esm/effects/PitchShiftEffect.d.ts +44 -0
  33. package/dist/esm/effects/PitchShiftEffect.js +66 -0
  34. package/dist/esm/effects/PitchShiftEffect.js.map +1 -0
  35. package/dist/esm/effects/ReverbEffect.d.ts +37 -0
  36. package/dist/esm/effects/ReverbEffect.js +121 -0
  37. package/dist/esm/effects/ReverbEffect.js.map +1 -0
  38. package/dist/esm/effects/VocoderEffect.d.ts +48 -0
  39. package/dist/esm/effects/VocoderEffect.js +94 -0
  40. package/dist/esm/effects/VocoderEffect.js.map +1 -0
  41. package/dist/esm/index.d.ts +13 -0
  42. package/dist/esm/index.js +12 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/worklets/beat-detector.worklet.d.ts +1 -0
  45. package/dist/esm/worklets/beat-detector.worklet.js +647 -0
  46. package/dist/esm/worklets/beat-detector.worklet.js.map +1 -0
  47. package/dist/esm/worklets/granular.worklet.d.ts +1 -0
  48. package/dist/esm/worklets/granular.worklet.js +89 -0
  49. package/dist/esm/worklets/granular.worklet.js.map +1 -0
  50. package/dist/esm/worklets/pitch-shift.worklet.d.ts +1 -0
  51. package/dist/esm/worklets/pitch-shift.worklet.js +74 -0
  52. package/dist/esm/worklets/pitch-shift.worklet.js.map +1 -0
  53. package/dist/esm/worklets/vocoder.worklet.d.ts +1 -0
  54. package/dist/esm/worklets/vocoder.worklet.js +92 -0
  55. package/dist/esm/worklets/vocoder.worklet.js.map +1 -0
  56. package/package.json +46 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Mel-scale filterbank generator.
3
+ *
4
+ * Generates `numBands` triangular filters log-spaced from `fMin` to `fMax` Hz
5
+ * on the mel scale. Each filter is a typed array of weights for the FFT
6
+ * magnitude bins.
7
+ *
8
+ * These helpers are also inlined inside the beat-detector worklet source
9
+ * string (worklets cannot import modules).
10
+ */
11
+ /** Convert Hz to mel. */
12
+ export declare function hzToMel(hz: number): number;
13
+ /** Convert mel to Hz. */
14
+ export declare function melToHz(mel: number): number;
15
+ export interface MelBand {
16
+ /** Index of the FFT bin where this filter starts (weight 0). */
17
+ readonly startBin: number;
18
+ /** Index of the peak FFT bin (weight 1). */
19
+ readonly peakBin: number;
20
+ /** Index of the FFT bin where this filter ends (weight 0). */
21
+ readonly endBin: number;
22
+ /** Pre-computed triangular weights, indexed from startBin..endBin (inclusive). */
23
+ readonly weights: Float32Array;
24
+ }
25
+ /**
26
+ * Build a mel filterbank.
27
+ *
28
+ * @param numBands Number of mel bands (default 24).
29
+ * @param fMin Lowest frequency in Hz (default 80).
30
+ * @param fMax Highest frequency in Hz (default 8000).
31
+ * @param fftSize Number of FFT points (e.g., 2048).
32
+ * @param sampleRate Audio sample rate in Hz (e.g., 48000).
33
+ */
34
+ export declare function buildMelFilterbank(bandCount: number, fMin: number, fMax: number, fftSize: number, sampleRate: number): MelBand[];
35
+ /**
36
+ * Compute mel band energies from a magnitude spectrum.
37
+ *
38
+ * @param mag FFT magnitude spectrum (length = fftSize/2).
39
+ * @param bands Filterbank from `buildMelFilterbank`.
40
+ * @param out Optional pre-allocated output array of length `bands.length`.
41
+ * @returns Log-compressed mel band energies.
42
+ */
43
+ export declare function computeMelBands(mag: Float32Array, bands: MelBand[], out?: Float32Array): Float32Array;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Mel-scale filterbank generator.
3
+ *
4
+ * Generates `numBands` triangular filters log-spaced from `fMin` to `fMax` Hz
5
+ * on the mel scale. Each filter is a typed array of weights for the FFT
6
+ * magnitude bins.
7
+ *
8
+ * These helpers are also inlined inside the beat-detector worklet source
9
+ * string (worklets cannot import modules).
10
+ */
11
+ /** Convert Hz to mel. */
12
+ function hzToMel(hz) {
13
+ return 2595 * Math.log10(1 + hz / 700);
14
+ }
15
+ /** Convert mel to Hz. */
16
+ function melToHz(mel) {
17
+ return 700 * (Math.pow(10, mel / 2595) - 1);
18
+ }
19
+ /**
20
+ * Build a mel filterbank.
21
+ *
22
+ * @param numBands Number of mel bands (default 24).
23
+ * @param fMin Lowest frequency in Hz (default 80).
24
+ * @param fMax Highest frequency in Hz (default 8000).
25
+ * @param fftSize Number of FFT points (e.g., 2048).
26
+ * @param sampleRate Audio sample rate in Hz (e.g., 48000).
27
+ */
28
+ function buildMelFilterbank(bandCount, fMin, fMax, fftSize, sampleRate) {
29
+ const binCount = fftSize >> 1; // positive frequencies
30
+ const nyquist = sampleRate / 2;
31
+ // Equally-spaced mel points: bandCount+2 points spanning fMin..fMax
32
+ const melMin = hzToMel(fMin);
33
+ const melMax = hzToMel(fMax);
34
+ const melPoints = new Float32Array(bandCount + 2);
35
+ for (let i = 0; i < bandCount + 2; i++) {
36
+ melPoints[i] = melMin + ((melMax - melMin) * i) / (bandCount + 1);
37
+ }
38
+ // Convert mel points to FFT bin indices
39
+ const binPoints = new Float32Array(bandCount + 2);
40
+ for (let i = 0; i < bandCount + 2; i++) {
41
+ const hz = melToHz(melPoints[i]);
42
+ binPoints[i] = Math.round((hz / nyquist) * (binCount - 1));
43
+ }
44
+ const bands = [];
45
+ for (let b = 0; b < bandCount; b++) {
46
+ const startBin = Math.max(0, Math.min(binCount - 1, binPoints[b]));
47
+ const peakBin = Math.max(0, Math.min(binCount - 1, binPoints[b + 1]));
48
+ const endBin = Math.max(0, Math.min(binCount - 1, binPoints[b + 2]));
49
+ const len = endBin - startBin + 1;
50
+ const weights = new Float32Array(len);
51
+ for (let i = 0; i < len; i++) {
52
+ const bin = startBin + i;
53
+ if (bin <= peakBin && peakBin > startBin) {
54
+ weights[i] = (bin - startBin) / (peakBin - startBin);
55
+ }
56
+ else if (bin > peakBin && endBin > peakBin) {
57
+ weights[i] = (endBin - bin) / (endBin - peakBin);
58
+ }
59
+ else {
60
+ // Degenerate: startBin === peakBin === endBin
61
+ weights[i] = 1;
62
+ }
63
+ }
64
+ bands.push({ startBin, peakBin, endBin, weights });
65
+ }
66
+ return bands;
67
+ }
68
+
69
+ export { buildMelFilterbank, hzToMel, melToHz };
70
+ //# sourceMappingURL=mel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mel.js","sources":["../../../../src/dsp/mel.ts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G,GAAG,KAAK,MAAM,GAAG,OAAO,CAAC;YAClD;iBAAO;;AAEL,gBAAA,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;YAChB;QACF;AAEA,QAAA,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACpD;AAEA,IAAA,OAAO,KAAK;AACd;;;;"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Autocorrelation-based tempogram.
3
+ *
4
+ * Given a novelty (onset-strength) curve sampled at rate `hopRate = sampleRate / hopSize`,
5
+ * this module computes the autocorrelation function (ACF) over a sliding window
6
+ * and returns the top tempo candidates.
7
+ *
8
+ * These helpers are also inlined inside the beat-detector worklet source string
9
+ * (worklets cannot import modules).
10
+ */
11
+ export interface TempoCandidateResult {
12
+ /** BPM value. */
13
+ bpm: number;
14
+ /** Normalised peak score (0..1). */
15
+ score: number;
16
+ /** ACF lag in hops that produced this peak. */
17
+ lag: number;
18
+ }
19
+ /**
20
+ * Compute the normalised autocorrelation function over a novelty curve.
21
+ *
22
+ * @param flux Recent novelty values (ring-buffer contents, oldest first).
23
+ * @param minLag Minimum lag in samples (inclusive).
24
+ * @param maxLag Maximum lag in samples (inclusive).
25
+ * @returns ACF array indexed by lag (index 0 = lag minLag).
26
+ */
27
+ export declare function computeAcf(flux: Float32Array, minLag: number, maxLag: number): Float32Array;
28
+ /**
29
+ * Find the top-K peaks in the ACF and convert lags to BPM candidates.
30
+ *
31
+ * @param acf Normalised ACF from `computeACF`.
32
+ * @param minLag The lag (in hops) corresponding to acf[0].
33
+ * @param hopSize Number of audio samples per hop.
34
+ * @param sampleRate Audio sample rate in Hz.
35
+ * @param topK Number of peaks to return (default 3).
36
+ * @returns Up to `topK` tempo candidates sorted by score descending.
37
+ */
38
+ export declare function findTempoPeaks(acf: Float32Array, minLag: number, hopSize: number, sampleRate: number, topK?: number): TempoCandidateResult[];
39
+ /**
40
+ * Apply hysteresis to tempo candidate selection.
41
+ *
42
+ * Prevents rapid switching between tempo estimates:
43
+ * - Only switches to a new best if its score is > currentBestScore * 1.15.
44
+ * - Octave-related candidates (2x or 0.5x) require a score > 1.5x to switch.
45
+ *
46
+ * @param candidates Sorted candidates from `findTempoPeaks`.
47
+ * @param currentBpm Currently tracked BPM.
48
+ * @param currentScore Currently tracked best score.
49
+ * @returns The selected best BPM.
50
+ */
51
+ export declare function applyTempoHysteresis(candidates: TempoCandidateResult[], currentBpm: number, currentScore: number): number;
@@ -0,0 +1,53 @@
1
+ import { AudioEffect } from '@codexo/exojs';
2
+ /** Construction options for {@link ChorusEffect}. */
3
+ export interface ChorusEffectOptions {
4
+ /** Base delay in ms. Typical 15-30ms. Default 25. */
5
+ delayMs?: number;
6
+ /** Modulation depth in ms (peak deviation from base). Default 5. */
7
+ depthMs?: number;
8
+ /** LFO rate in Hz. Typical 0.1-5Hz for chorus, 5-15Hz for vibrato. Default 1.5. */
9
+ rateHz?: number;
10
+ /** Dry/wet mix, 0..1. Default 0.5 (equal mix). */
11
+ wet?: number;
12
+ }
13
+ /**
14
+ * Chorus effect using native WebAudio nodes (no worklet required).
15
+ *
16
+ * The signal splits into a dry path and a wet path. The wet path passes
17
+ * through a DelayNode whose delay time is modulated by a sine-wave LFO,
18
+ * producing the characteristic pitch-wobble / thickening of chorus.
19
+ *
20
+ * Node graph:
21
+ * ```
22
+ * inputGain ┬── dryGain ────────────────┐
23
+ * │ ├── outputGain
24
+ * └── delayNode ── wetGain ────┘
25
+ *
26
+ * lfoOscillator ── lfoGain (depth) ── delayNode.delayTime
27
+ * ```
28
+ */
29
+ export declare class ChorusEffect extends AudioEffect {
30
+ private _nodes;
31
+ private _delayMs;
32
+ private readonly _onAudioContextReady;
33
+ private _depthMs;
34
+ private _rateHz;
35
+ private _wet;
36
+ constructor(options?: ChorusEffectOptions);
37
+ get inputNode(): AudioNode;
38
+ get outputNode(): AudioNode;
39
+ /** Base delay time in milliseconds. Default 25. */
40
+ get delayMs(): number;
41
+ set delayMs(value: number);
42
+ /** LFO modulation depth in milliseconds (peak deviation from base delay). Default 5. */
43
+ get depthMs(): number;
44
+ set depthMs(value: number);
45
+ /** LFO oscillation rate in Hz. Typical chorus range is 0.1–5 Hz; 5–15 Hz produces a vibrato effect. Default 1.5. */
46
+ get rateHz(): number;
47
+ set rateHz(value: number);
48
+ /** Wet (modulated) mix level, 0..1. The dry level is automatically `1 - wet`. Default 0.5. */
49
+ get wet(): number;
50
+ set wet(value: number);
51
+ destroy(): void;
52
+ private _setupNodes;
53
+ }
@@ -0,0 +1,154 @@
1
+ import { AudioEffect, onAudioContextReady, isAudioContextReady, getAudioContext } from '@codexo/exojs';
2
+
3
+ /**
4
+ * Chorus effect using native WebAudio nodes (no worklet required).
5
+ *
6
+ * The signal splits into a dry path and a wet path. The wet path passes
7
+ * through a DelayNode whose delay time is modulated by a sine-wave LFO,
8
+ * producing the characteristic pitch-wobble / thickening of chorus.
9
+ *
10
+ * Node graph:
11
+ * ```
12
+ * inputGain ┬── dryGain ────────────────┐
13
+ * │ ├── outputGain
14
+ * └── delayNode ── wetGain ────┘
15
+ *
16
+ * lfoOscillator ── lfoGain (depth) ── delayNode.delayTime
17
+ * ```
18
+ */
19
+ class ChorusEffect extends AudioEffect {
20
+ _nodes = null;
21
+ _delayMs;
22
+ _onAudioContextReady = (ctx) => {
23
+ onAudioContextReady.remove(this._onAudioContextReady);
24
+ this._setupNodes(ctx);
25
+ };
26
+ _depthMs;
27
+ _rateHz;
28
+ _wet;
29
+ constructor(options = {}) {
30
+ super();
31
+ this._delayMs = Math.max(0, options.delayMs ?? 25);
32
+ this._depthMs = Math.max(0, options.depthMs ?? 5);
33
+ this._rateHz = Math.max(0, options.rateHz ?? 1.5);
34
+ this._wet = Math.max(0, Math.min(1, options.wet ?? 0.5));
35
+ if (isAudioContextReady()) {
36
+ this._setupNodes(getAudioContext());
37
+ }
38
+ else {
39
+ onAudioContextReady.add(this._onAudioContextReady);
40
+ }
41
+ }
42
+ get inputNode() {
43
+ if (!this._nodes)
44
+ throw new Error('ChorusEffect not yet initialized.');
45
+ return this._nodes.inputGain;
46
+ }
47
+ get outputNode() {
48
+ if (!this._nodes)
49
+ throw new Error('ChorusEffect not yet initialized.');
50
+ return this._nodes.outputGain;
51
+ }
52
+ // -------------------------------------------------------------------------
53
+ // Getters / setters
54
+ // -------------------------------------------------------------------------
55
+ /** Base delay time in milliseconds. Default 25. */
56
+ get delayMs() {
57
+ return this._delayMs;
58
+ }
59
+ set delayMs(value) {
60
+ this._delayMs = Math.max(0, value);
61
+ if (this._nodes) {
62
+ this._nodes.delayNode.delayTime.setTargetAtTime(this._delayMs / 1000, this._nodes.delayNode.context.currentTime, 0.01);
63
+ }
64
+ }
65
+ /** LFO modulation depth in milliseconds (peak deviation from base delay). Default 5. */
66
+ get depthMs() {
67
+ return this._depthMs;
68
+ }
69
+ set depthMs(value) {
70
+ this._depthMs = Math.max(0, value);
71
+ if (this._nodes) {
72
+ this._nodes.lfoGain.gain.setTargetAtTime(this._depthMs / 1000, this._nodes.lfoGain.context.currentTime, 0.01);
73
+ }
74
+ }
75
+ /** LFO oscillation rate in Hz. Typical chorus range is 0.1–5 Hz; 5–15 Hz produces a vibrato effect. Default 1.5. */
76
+ get rateHz() {
77
+ return this._rateHz;
78
+ }
79
+ set rateHz(value) {
80
+ this._rateHz = Math.max(0, value);
81
+ if (this._nodes) {
82
+ this._nodes.lfoOscillator.frequency.setTargetAtTime(this._rateHz, this._nodes.inputGain.context.currentTime, 0.01);
83
+ }
84
+ }
85
+ /** Wet (modulated) mix level, 0..1. The dry level is automatically `1 - wet`. Default 0.5. */
86
+ get wet() {
87
+ return this._wet;
88
+ }
89
+ set wet(value) {
90
+ this._wet = Math.max(0, Math.min(1, value));
91
+ if (this._nodes) {
92
+ const ctx = this._nodes.wetGain.context;
93
+ this._nodes.wetGain.gain.setTargetAtTime(this._wet, ctx.currentTime, 0.01);
94
+ this._nodes.dryGain.gain.setTargetAtTime(1 - this._wet, ctx.currentTime, 0.01);
95
+ }
96
+ }
97
+ // -------------------------------------------------------------------------
98
+ // Lifecycle
99
+ // -------------------------------------------------------------------------
100
+ destroy() {
101
+ onAudioContextReady.remove(this._onAudioContextReady);
102
+ if (this._nodes) {
103
+ this._nodes.lfoOscillator.stop();
104
+ this._nodes.lfoOscillator.disconnect();
105
+ this._nodes.lfoGain.disconnect();
106
+ this._nodes.delayNode.disconnect();
107
+ this._nodes.dryGain.disconnect();
108
+ this._nodes.wetGain.disconnect();
109
+ this._nodes.inputGain.disconnect();
110
+ this._nodes.outputGain.disconnect();
111
+ this._nodes = null;
112
+ }
113
+ }
114
+ // -------------------------------------------------------------------------
115
+ // Private
116
+ // -------------------------------------------------------------------------
117
+ _setupNodes(ctx) {
118
+ const inputGain = ctx.createGain();
119
+ const outputGain = ctx.createGain();
120
+ const dryGain = ctx.createGain();
121
+ const wetGain = ctx.createGain();
122
+ // maxDelayTime must be larger than base + peak depth, with a small buffer.
123
+ const maxDelay = (this._delayMs + this._depthMs) / 1000 + 0.05;
124
+ const delayNode = ctx.createDelay(maxDelay);
125
+ const lfoGain = ctx.createGain();
126
+ // Initial values
127
+ inputGain.gain.setValueAtTime(1, ctx.currentTime);
128
+ outputGain.gain.setValueAtTime(1, ctx.currentTime);
129
+ dryGain.gain.setValueAtTime(1 - this._wet, ctx.currentTime);
130
+ wetGain.gain.setValueAtTime(this._wet, ctx.currentTime);
131
+ delayNode.delayTime.setValueAtTime(this._delayMs / 1000, ctx.currentTime);
132
+ lfoGain.gain.setValueAtTime(this._depthMs / 1000, ctx.currentTime);
133
+ // LFO
134
+ const lfoOscillator = ctx.createOscillator();
135
+ lfoOscillator.type = 'sine';
136
+ lfoOscillator.frequency.value = this._rateHz;
137
+ // Wiring
138
+ // LFO → lfoGain → delayNode.delayTime (AudioParam)
139
+ lfoOscillator.connect(lfoGain);
140
+ lfoGain.connect(delayNode.delayTime);
141
+ // Dry path: inputGain → dryGain → outputGain
142
+ inputGain.connect(dryGain);
143
+ dryGain.connect(outputGain);
144
+ // Wet path: inputGain → delayNode → wetGain → outputGain
145
+ inputGain.connect(delayNode);
146
+ delayNode.connect(wetGain);
147
+ wetGain.connect(outputGain);
148
+ lfoOscillator.start();
149
+ this._nodes = { inputGain, outputGain, dryGain, wetGain, delayNode, lfoOscillator, lfoGain };
150
+ }
151
+ }
152
+
153
+ export { ChorusEffect };
154
+ //# sourceMappingURL=ChorusEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChorusEffect.js","sources":["../../../../src/effects/ChorusEffect.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAwBA;;;;;;;;;;;;;;;AAeG;AACG,MAAO,YAAa,SAAQ,WAAW,CAAA;IACnC,MAAM,GAA6B,IAAI;AACvC,IAAA,QAAQ;AACC,IAAA,oBAAoB,GAAG,CAAC,GAAiB,KAAU;AAClE,QAAA,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;AACrD,QAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;AACvB,IAAA,CAAC;AACO,IAAA,QAAQ;AACR,IAAA,OAAO;AACP,IAAA,IAAI;AAEZ,IAAA,WAAA,CAAmB,UAA+B,EAAE,EAAA;AAClD,QAAA,KAAK,EAAE;AACP,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AAClD,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;AACjD,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GA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AAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC;AAC3D,QAAA,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC;AACvD,QAAA,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC;AACzE,QAAA,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,GAAG,CAAC,WAAW,CAAC;;AAGlE,QAAA,MAAM,aAAa,GAAG,GAAG,CAAC,gBAAgB,EAAE;AAC5C,QAAA,aAAa,CAAC,IAAI,GAAG,MAAM;QAC3B,aAAa,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO;;;AAI5C,QAAA,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC;AAC9B,QAAA,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,SAAiC,CAAC;;AAG5D,QAAA,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;AAC1B,QAAA,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;;AAG3B,QAAA,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;AAC5B,QAAA,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;AAC1B,QAAA,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;QAE3B,aAAa,CAAC,KAAK,EAAE;AAErB,QAAA,IAAI,CAAC,MAAM,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE;IAC9F;AACD;;;;"}
@@ -0,0 +1,53 @@
1
+ import { AudioEffect } from '@codexo/exojs';
2
+ /** Construction options for {@link CompressorEffect}. All values are clamped to their valid ranges on assignment. */
3
+ export interface CompressorEffectOptions {
4
+ threshold?: number;
5
+ knee?: number;
6
+ ratio?: number;
7
+ attack?: number;
8
+ release?: number;
9
+ }
10
+ /**
11
+ * Dynamic-range compressor backed by a Web Audio `DynamicsCompressorNode`.
12
+ * Reduces the volume of loud signals above a threshold, evening out the
13
+ * perceived loudness of a mix. All parameter changes are applied with a short
14
+ * smoothing ramp so they are artifact-free during playback.
15
+ */
16
+ export declare class CompressorEffect extends AudioEffect {
17
+ private _node;
18
+ private _threshold;
19
+ private readonly _onAudioContextReady;
20
+ private _knee;
21
+ private _ratio;
22
+ private _attack;
23
+ private _release;
24
+ constructor(options?: CompressorEffectOptions);
25
+ get inputNode(): AudioNode;
26
+ get outputNode(): AudioNode;
27
+ /** Level above which compression begins, in dBFS. Range −100..0, default −24. */
28
+ get threshold(): number;
29
+ set threshold(value: number);
30
+ /** Width in dB of the transition region around the threshold (soft knee). Range 0..40, default 30. */
31
+ get knee(): number;
32
+ set knee(value: number);
33
+ /** Input-to-output dB ratio above the threshold. Range 1..20, default 12. */
34
+ get ratio(): number;
35
+ set ratio(value: number);
36
+ /** Time in seconds for the compressor to engage after the signal exceeds the threshold. Range 0..1, default 0.003. */
37
+ get attack(): number;
38
+ set attack(value: number);
39
+ /** Time in seconds for the compressor to disengage after the signal drops below the threshold. Range 0..1, default 0.25. */
40
+ get release(): number;
41
+ set release(value: number);
42
+ /**
43
+ * Live gain reduction in dB applied by the compressor right now. Always
44
+ * `<= 0` (or `0` when the compressor isn't engaging). Read-only — drive
45
+ * input level meters / sidechain visualisations off this value.
46
+ *
47
+ * Returns `0` until the underlying node has been created (before the
48
+ * audio context is ready).
49
+ */
50
+ get reduction(): number;
51
+ destroy(): void;
52
+ private _setup;
53
+ }
@@ -0,0 +1,122 @@
1
+ import { AudioEffect, onAudioContextReady, isAudioContextReady, getAudioContext } from '@codexo/exojs';
2
+
3
+ /**
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
+ }
120
+
121
+ export { CompressorEffect };
122
+ //# sourceMappingURL=CompressorEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompressorEff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AI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;QACzF;IACF;AAEA;;;;;;;AAOG;AACH,IAAA,IAAW,SAAS,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC;IACnC;IAEgB,OAAO,GAAA;AACrB,QAAA,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;AACrD,QAAA,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE;AACxB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;IACnB;AAEQ,IAAA,MAAM,CAAC,GAAiB,EAAA;AAC9B,QAAA,MAAM,IAAI,GAAG,GAAG,CAAC,wBAAwB,EAAE;AAC3C,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;;;;"}
@@ -0,0 +1,35 @@
1
+ import { AudioEffect } from '@codexo/exojs';
2
+ /** Construction options for {@link DelayEffect}. */
3
+ export interface DelayEffectOptions {
4
+ delaySeconds?: number;
5
+ feedback?: number;
6
+ wet?: number;
7
+ }
8
+ /**
9
+ * Echo/delay effect using a Web Audio `DelayNode` with a feedback loop and
10
+ * dry/wet mix. The feedback path feeds the delayed signal back into itself,
11
+ * producing repeating echoes that decay naturally. Setting `feedback` near
12
+ * its maximum of 0.95 produces a long, prominent tail; lower values create
13
+ * a single slap-back echo.
14
+ */
15
+ export declare class DelayEffect extends AudioEffect {
16
+ private _setup;
17
+ private _delaySeconds;
18
+ private readonly _onAudioContextReady;
19
+ private _feedback;
20
+ private _wet;
21
+ constructor(options?: DelayEffectOptions);
22
+ get inputNode(): AudioNode;
23
+ get outputNode(): AudioNode;
24
+ /** Delay time in seconds. Range 0..5, default 0.3. */
25
+ get delaySeconds(): number;
26
+ set delaySeconds(value: number);
27
+ /** Fraction of the delayed signal fed back into the delay input. Range 0..0.95, default 0.4. */
28
+ get feedback(): number;
29
+ set feedback(value: number);
30
+ /** Wet (delayed) mix level, 0..1. The dry level is automatically `1 - wet`. Default 0.5. */
31
+ get wet(): number;
32
+ set wet(value: number);
33
+ destroy(): void;
34
+ private _setupNodes;
35
+ }