@codexo/exojs-audio-fx 0.19.0 → 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 (117) 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 -125
  6. package/dist/esm/AudioAnalyser.d.ts.map +0 -1
  7. package/dist/esm/AudioAnalyser.js +0 -369
  8. package/dist/esm/AudioAnalyser.js.map +0 -1
  9. package/dist/esm/BeatDetector.d.ts +0 -286
  10. package/dist/esm/BeatDetector.d.ts.map +0 -1
  11. package/dist/esm/BeatDetector.js +0 -419
  12. package/dist/esm/BeatDetector.js.map +0 -1
  13. package/dist/esm/PcmStreamSource.d.ts +0 -127
  14. package/dist/esm/PcmStreamSource.d.ts.map +0 -1
  15. package/dist/esm/PcmStreamSource.js +0 -308
  16. package/dist/esm/PcmStreamSource.js.map +0 -1
  17. package/dist/esm/dsp/fft.d.ts +0 -22
  18. package/dist/esm/dsp/fft.d.ts.map +0 -1
  19. package/dist/esm/dsp/mel.d.ts +0 -43
  20. package/dist/esm/dsp/mel.d.ts.map +0 -1
  21. package/dist/esm/dsp/mel.js +0 -61
  22. package/dist/esm/dsp/mel.js.map +0 -1
  23. package/dist/esm/dsp/tempogram.d.ts +0 -192
  24. package/dist/esm/dsp/tempogram.d.ts.map +0 -1
  25. package/dist/esm/effects/AutoWahEffect.d.ts +0 -128
  26. package/dist/esm/effects/AutoWahEffect.d.ts.map +0 -1
  27. package/dist/esm/effects/AutoWahEffect.js +0 -214
  28. package/dist/esm/effects/AutoWahEffect.js.map +0 -1
  29. package/dist/esm/effects/BitCrusherEffect.d.ts +0 -64
  30. package/dist/esm/effects/BitCrusherEffect.d.ts.map +0 -1
  31. package/dist/esm/effects/BitCrusherEffect.js +0 -76
  32. package/dist/esm/effects/BitCrusherEffect.js.map +0 -1
  33. package/dist/esm/effects/ChorusEffect.d.ts +0 -54
  34. package/dist/esm/effects/ChorusEffect.d.ts.map +0 -1
  35. package/dist/esm/effects/ChorusEffect.js +0 -136
  36. package/dist/esm/effects/ChorusEffect.js.map +0 -1
  37. package/dist/esm/effects/CompressorEffect.d.ts +0 -56
  38. package/dist/esm/effects/CompressorEffect.d.ts.map +0 -1
  39. package/dist/esm/effects/CompressorEffect.js +0 -108
  40. package/dist/esm/effects/CompressorEffect.js.map +0 -1
  41. package/dist/esm/effects/ConvolutionEffect.d.ts +0 -119
  42. package/dist/esm/effects/ConvolutionEffect.d.ts.map +0 -1
  43. package/dist/esm/effects/ConvolutionEffect.js +0 -212
  44. package/dist/esm/effects/ConvolutionEffect.js.map +0 -1
  45. package/dist/esm/effects/DelayEffect.d.ts +0 -36
  46. package/dist/esm/effects/DelayEffect.d.ts.map +0 -1
  47. package/dist/esm/effects/DelayEffect.js +0 -109
  48. package/dist/esm/effects/DelayEffect.js.map +0 -1
  49. package/dist/esm/effects/DistortionEffect.d.ts +0 -120
  50. package/dist/esm/effects/DistortionEffect.d.ts.map +0 -1
  51. package/dist/esm/effects/DistortionEffect.js +0 -194
  52. package/dist/esm/effects/DistortionEffect.js.map +0 -1
  53. package/dist/esm/effects/DuckingEffect.d.ts +0 -44
  54. package/dist/esm/effects/DuckingEffect.d.ts.map +0 -1
  55. package/dist/esm/effects/DuckingEffect.js +0 -95
  56. package/dist/esm/effects/DuckingEffect.js.map +0 -1
  57. package/dist/esm/effects/EqualizerEffect.d.ts +0 -51
  58. package/dist/esm/effects/EqualizerEffect.d.ts.map +0 -1
  59. package/dist/esm/effects/EqualizerEffect.js +0 -124
  60. package/dist/esm/effects/EqualizerEffect.js.map +0 -1
  61. package/dist/esm/effects/FlangerEffect.d.ts +0 -99
  62. package/dist/esm/effects/FlangerEffect.d.ts.map +0 -1
  63. package/dist/esm/effects/FlangerEffect.js +0 -176
  64. package/dist/esm/effects/FlangerEffect.js.map +0 -1
  65. package/dist/esm/effects/GranularEffect.d.ts +0 -67
  66. package/dist/esm/effects/GranularEffect.d.ts.map +0 -1
  67. package/dist/esm/effects/GranularEffect.js +0 -104
  68. package/dist/esm/effects/GranularEffect.js.map +0 -1
  69. package/dist/esm/effects/LimiterEffect.d.ts +0 -125
  70. package/dist/esm/effects/LimiterEffect.d.ts.map +0 -1
  71. package/dist/esm/effects/LimiterEffect.js +0 -186
  72. package/dist/esm/effects/LimiterEffect.js.map +0 -1
  73. package/dist/esm/effects/PhaserEffect.d.ts +0 -127
  74. package/dist/esm/effects/PhaserEffect.d.ts.map +0 -1
  75. package/dist/esm/effects/PhaserEffect.js +0 -218
  76. package/dist/esm/effects/PhaserEffect.js.map +0 -1
  77. package/dist/esm/effects/PingPongDelayEffect.d.ts +0 -84
  78. package/dist/esm/effects/PingPongDelayEffect.d.ts.map +0 -1
  79. package/dist/esm/effects/PingPongDelayEffect.js +0 -176
  80. package/dist/esm/effects/PingPongDelayEffect.js.map +0 -1
  81. package/dist/esm/effects/PitchShiftEffect.d.ts +0 -46
  82. package/dist/esm/effects/PitchShiftEffect.d.ts.map +0 -1
  83. package/dist/esm/effects/PitchShiftEffect.js +0 -64
  84. package/dist/esm/effects/PitchShiftEffect.js.map +0 -1
  85. package/dist/esm/effects/ReverbEffect.d.ts +0 -38
  86. package/dist/esm/effects/ReverbEffect.d.ts.map +0 -1
  87. package/dist/esm/effects/ReverbEffect.js +0 -117
  88. package/dist/esm/effects/ReverbEffect.js.map +0 -1
  89. package/dist/esm/effects/RingModulatorEffect.d.ts +0 -96
  90. package/dist/esm/effects/RingModulatorEffect.d.ts.map +0 -1
  91. package/dist/esm/effects/RingModulatorEffect.js +0 -157
  92. package/dist/esm/effects/RingModulatorEffect.js.map +0 -1
  93. package/dist/esm/effects/TremoloEffect.d.ts +0 -111
  94. package/dist/esm/effects/TremoloEffect.d.ts.map +0 -1
  95. package/dist/esm/effects/TremoloEffect.js +0 -197
  96. package/dist/esm/effects/TremoloEffect.js.map +0 -1
  97. package/dist/esm/effects/VocoderEffect.d.ts +0 -45
  98. package/dist/esm/effects/VocoderEffect.d.ts.map +0 -1
  99. package/dist/esm/effects/VocoderEffect.js +0 -73
  100. package/dist/esm/effects/VocoderEffect.js.map +0 -1
  101. package/dist/esm/index.d.ts +0 -25
  102. package/dist/esm/index.d.ts.map +0 -1
  103. package/dist/esm/index.js +0 -24
  104. package/dist/esm/worklets/beat-detector.worklet.js +0 -6
  105. package/dist/esm/worklets/beat-detector.worklet.js.map +0 -1
  106. package/dist/esm/worklets/bit-crusher.worklet.js +0 -6
  107. package/dist/esm/worklets/bit-crusher.worklet.js.map +0 -1
  108. package/dist/esm/worklets/ducking.worklet.js +0 -6
  109. package/dist/esm/worklets/ducking.worklet.js.map +0 -1
  110. package/dist/esm/worklets/granular.worklet.js +0 -6
  111. package/dist/esm/worklets/granular.worklet.js.map +0 -1
  112. package/dist/esm/worklets/pcm-stream.worklet.js +0 -6
  113. package/dist/esm/worklets/pcm-stream.worklet.js.map +0 -1
  114. package/dist/esm/worklets/pitch-shift.worklet.js +0 -6
  115. package/dist/esm/worklets/pitch-shift.worklet.js.map +0 -1
  116. package/dist/esm/worklets/vocoder.worklet.js +0 -6
  117. package/dist/esm/worklets/vocoder.worklet.js.map +0 -1
@@ -1,419 +0,0 @@
1
- import beat_detector_worklet_default from "./worklets/beat-detector.worklet.js";
2
- import { Signal, getAudioContext, isAudioContextReady, onAudioContextReady, registerAudioWorkletProcessor } from "@codexo/exojs";
3
-
4
- //#region src/BeatDetector.ts
5
- const workletName = "exojs-beat-detector";
6
- /**
7
- * Real-time tempo + beat tracker. Splits work between the audio-rendering
8
- * thread (an AudioWorklet that runs onset detection, tempogram analysis,
9
- * and parallel 3/4 and 4/4 posterior estimation) and the main thread (this
10
- * class - receives beats, fires Signals, handles configuration and source
11
- * routing).
12
- *
13
- * Accepts a wide range of {@link BeatDetectorSource}s - a bus, an individual
14
- * {@link Voice}, a raw MediaStream, or any AudioNode - and exposes a Signal
15
- * for each notable event:
16
- * - {@link BeatDetector.onBeat} - every detected beat
17
- * - {@link BeatDetector.onDownbeat} - first beat of each bar
18
- * - {@link BeatDetector.onBarStart} - bar boundary
19
- * - {@link BeatDetector.onTempoChange} - when the tracked BPM changes
20
- * - {@link BeatDetector.onBeatPredicted} - look-ahead schedule notice
21
- *
22
- * Early beats arrive with low latency tagged `status: 'provisional'` (after a
23
- * short `minSettlingMs` warm-up, default 400 ms) for snappy visual reactivity,
24
- * then promote to `status: 'locked'` once the tempo grid is trustworthy - a
25
- * single {@link BeatDetector.onBeat} signal carries both via {@link BeatInfo.status}.
26
- * Set `emitProvisionalBeats: false` to receive only locked beats. Time-signature
27
- * detection (3/4 vs 4/4) is on by default; lock to 4/4 by setting
28
- * `enableTimeSignatureDetection: false`.
29
- */
30
- var BeatDetector = class {
31
- onBeat = new Signal();
32
- onTempoChange = new Signal();
33
- onDownbeat = new Signal();
34
- onBarStart = new Signal();
35
- onBeatPredicted = new Signal();
36
- _options;
37
- _workletNode = null;
38
- _source = null;
39
- _tapSource = null;
40
- _streamSource = null;
41
- _ready = null;
42
- _pendingSourceSetup = null;
43
- _onAudioContextReady = (ctx) => {
44
- onAudioContextReady.remove(this._onAudioContextReady);
45
- this._setup(ctx);
46
- };
47
- _tempo = 0;
48
- _beatPhase = 0;
49
- _nextBeatTime = 0;
50
- _confidence = 0;
51
- _phaseConfidence = 0;
52
- _gridStability = 0;
53
- _analysisTime = 0;
54
- _analysisLatency = 0;
55
- _tempoCandidates = [];
56
- _rms = 0;
57
- _onsetStrength = 0;
58
- _bandEnergy = {
59
- low: 0,
60
- mid: 0,
61
- high: 0
62
- };
63
- _barPosition = 1;
64
- _barLength = 4;
65
- _timeSignature = {
66
- numerator: 4,
67
- denominator: 4
68
- };
69
- _nextDownbeatTime = 0;
70
- _lookahead = Object.freeze([]);
71
- /**
72
- * Half-life in seconds for the {@link pulse} envelope. Mutable; default 0.15.
73
- * Smaller values give a snappier pulse, larger values a longer afterglow.
74
- */
75
- pulseHalfLife;
76
- /** Half-life for the {@link barPulse} envelope. Mutable; default 0.3. */
77
- barPulseHalfLife;
78
- /** Time window for {@link justBeat}. Mutable; default 0.03 (30ms). */
79
- justBeatWindow;
80
- constructor(options) {
81
- this._options = {
82
- minBpm: options?.minBpm ?? 50,
83
- maxBpm: options?.maxBpm ?? 300,
84
- fftSize: options?.fftSize ?? 2048,
85
- hopSize: options?.hopSize ?? 512,
86
- fastTempoWindowSec: options?.fastTempoWindowSec ?? 2.5,
87
- stableTempoWindowSec: options?.stableTempoWindowSec ?? 8,
88
- acfIntervalHops: options?.acfIntervalHops ?? 15,
89
- minSettlingMs: options?.minSettlingMs ?? 400,
90
- emitProvisionalBeats: options?.emitProvisionalBeats ?? true,
91
- melBands: options?.melBands ?? 24,
92
- enableTimeSignatureDetection: options?.enableTimeSignatureDetection ?? true,
93
- source: options?.source ?? null,
94
- pulseHalfLife: options?.pulseHalfLife ?? .15,
95
- barPulseHalfLife: options?.barPulseHalfLife ?? .3,
96
- justBeatWindow: options?.justBeatWindow ?? .03
97
- };
98
- this.pulseHalfLife = this._options.pulseHalfLife;
99
- this.barPulseHalfLife = this._options.barPulseHalfLife;
100
- this.justBeatWindow = this._options.justBeatWindow;
101
- if (isAudioContextReady()) this._setup(getAudioContext());
102
- else onAudioContextReady.add(this._onAudioContextReady);
103
- if (options?.source !== void 0 && options.source !== null) this.source = options.source;
104
- }
105
- get source() {
106
- return this._source;
107
- }
108
- set source(value) {
109
- if (value === this._source) return;
110
- this._disconnectTap();
111
- this._source = value;
112
- if (value === null) return;
113
- if (isAudioContextReady()) {
114
- this._pendingSourceSetup = null;
115
- this._connectSource(value, getAudioContext());
116
- } else {
117
- if (this._pendingSourceSetup !== null) onAudioContextReady.remove(this._pendingSourceSetup);
118
- const handler = (ctx) => {
119
- onAudioContextReady.remove(handler);
120
- this._pendingSourceSetup = null;
121
- this._connectSource(value, ctx);
122
- };
123
- this._pendingSourceSetup = handler;
124
- onAudioContextReady.add(handler);
125
- }
126
- }
127
- get ready() {
128
- return this._ready ?? Promise.resolve();
129
- }
130
- get tempo() {
131
- return this._tempo;
132
- }
133
- get beatPhase() {
134
- return this._beatPhase;
135
- }
136
- get nextBeatTime() {
137
- return this._nextBeatTime;
138
- }
139
- get confidence() {
140
- return this._confidence;
141
- }
142
- /**
143
- * How well recent onsets support the beat grid's phase, 0 to 1, or 0 before
144
- * the grid locks.
145
- *
146
- * Distinct from {@link confidence}, which reports how sure the detector is of
147
- * the tempo. A metronomic loop at a wrong-by-an-octave tempo reads high
148
- * confidence and high phase confidence; a rubato passage at a known tempo
149
- * reads high confidence and low phase confidence. Gate anything that must
150
- * land exactly on the beat - a scored hit, a quantised trigger - on this
151
- * rather than on {@link confidence}.
152
- */
153
- get phaseConfidence() {
154
- return this._phaseConfidence;
155
- }
156
- get gridStability() {
157
- return this._gridStability;
158
- }
159
- /**
160
- * The `AudioContext.currentTime` of the newest sample the current state
161
- * describes. 0 until the first state message arrives.
162
- *
163
- * Every timestamp this detector reports - this one, {@link BeatInfo.audioTime},
164
- * {@link nextBeatTime}, {@link lookahead} - is on the audio context's clock,
165
- * so `AudioOutputClock` converts them to the `performance.now()` timeline
166
- * without further correction.
167
- */
168
- get analysisTime() {
169
- return this._analysisTime;
170
- }
171
- /**
172
- * Seconds between {@link analysisTime} and the moment the main thread
173
- * received that state, measured rather than assumed.
174
- *
175
- * Covers the analysis hop and the worklet-to-main-thread delivery together,
176
- * and is quantised to the context's render-quantum boundary, so treat it as
177
- * a budget figure rather than an exact age. It says nothing about the output
178
- * path: what a listener hears lags the analysed audio by the output latency
179
- * on top, which `AudioOutputClock` reports.
180
- */
181
- get analysisLatency() {
182
- return this._analysisLatency;
183
- }
184
- get rms() {
185
- return this._rms;
186
- }
187
- get onsetStrength() {
188
- return this._onsetStrength;
189
- }
190
- get bandEnergy() {
191
- return this._bandEnergy;
192
- }
193
- get tempoCandidates() {
194
- return this._tempoCandidates;
195
- }
196
- get barPosition() {
197
- return this._barPosition;
198
- }
199
- get barLength() {
200
- return this._barLength;
201
- }
202
- get timeSignature() {
203
- return this._timeSignature;
204
- }
205
- get nextDownbeatTime() {
206
- return this._nextDownbeatTime;
207
- }
208
- get lookahead() {
209
- return this._lookahead;
210
- }
211
- /**
212
- * Seconds elapsed since the most recent beat, derived from {@link beatPhase}
213
- * and {@link tempo}. Returns 0 when the detector hasn't locked yet.
214
- */
215
- get secondsSinceLastBeat() {
216
- if (this._tempo === 0) return 0;
217
- return this._beatPhase * (60 / this._tempo);
218
- }
219
- /**
220
- * 0..1 envelope, peaks at 1.0 the moment a beat fires and halves every
221
- * {@link pulseHalfLife} seconds. Drives "pulse on the beat" visuals
222
- * with a single multiplication: `sprite.scale = 1 + clock.pulse * 0.3`.
223
- */
224
- get pulse() {
225
- if (this._tempo === 0) return 0;
226
- return Math.pow(.5, this.secondsSinceLastBeat / this.pulseHalfLife);
227
- }
228
- /**
229
- * Like {@link pulse} but resets on downbeats and decays per
230
- * {@link barPulseHalfLife}. Useful for emphasizing the first beat of
231
- * each bar (e.g. brighter flash on "1" vs "2,3,4").
232
- */
233
- get barPulse() {
234
- if (this._tempo === 0 || this._barLength === 0) return 0;
235
- const secondsPerBeat = 60 / this._tempo;
236
- const lastDownbeat = this._nextDownbeatTime - this._barLength * secondsPerBeat;
237
- const elapsed = Math.max(0, getAudioContext().currentTime - lastDownbeat);
238
- return Math.pow(.5, elapsed / this.barPulseHalfLife);
239
- }
240
- /**
241
- * True for the visual frame(s) within {@link justBeatWindow} seconds of
242
- * a beat onset. Use for one-shot triggers (strobe flash, particle burst,
243
- * sample retrigger). Default window 30ms covers a typical 60fps frame.
244
- */
245
- get justBeat() {
246
- return this._tempo > 0 && this.secondsSinceLastBeat < this.justBeatWindow;
247
- }
248
- /**
249
- * Phase 0..1 within a subdivision of the current beat. `division` is the
250
- * number of subdivisions per beat: 2 for 8th notes, 4 for 16th notes,
251
- * 3 for triplets. Use to drive sub-beat-resolution effects:
252
- *
253
- * const sixteenth = clock.subdivisionPhase(4);
254
- * if (sixteenth < 0.05) flash();
255
- */
256
- subdivisionPhase(division) {
257
- if (!Number.isFinite(division) || division <= 0) return 0;
258
- return this._beatPhase * division % 1;
259
- }
260
- destroy() {
261
- onAudioContextReady.remove(this._onAudioContextReady);
262
- if (this._pendingSourceSetup !== null) {
263
- onAudioContextReady.remove(this._pendingSourceSetup);
264
- this._pendingSourceSetup = null;
265
- }
266
- this._disconnectTap();
267
- this._workletNode?.disconnect();
268
- this._workletNode = null;
269
- this._ready = null;
270
- this.onBeat.clear();
271
- this.onTempoChange.clear();
272
- this.onDownbeat.clear();
273
- this.onBarStart.clear();
274
- this.onBeatPredicted.clear();
275
- }
276
- _setup(audioContext) {
277
- const opts = this._options;
278
- this._ready = registerAudioWorkletProcessor(audioContext, workletName, beat_detector_worklet_default).then(() => {
279
- const node = new AudioWorkletNode(audioContext, workletName, {
280
- numberOfInputs: 1,
281
- numberOfOutputs: 0,
282
- processorOptions: {
283
- fftSize: opts.fftSize,
284
- hopSize: opts.hopSize,
285
- minBpm: opts.minBpm,
286
- maxBpm: opts.maxBpm,
287
- melBands: opts.melBands,
288
- minSettlingMs: opts.minSettlingMs,
289
- emitProvisionalBeats: opts.emitProvisionalBeats,
290
- fastTempoWindowSec: opts.fastTempoWindowSec,
291
- stableTempoWindowSec: opts.stableTempoWindowSec,
292
- acfIntervalHops: opts.acfIntervalHops,
293
- enableTimeSignatureDetection: opts.enableTimeSignatureDetection
294
- }
295
- });
296
- this._workletNode = node;
297
- node.port.onmessage = this._onWorkletMessage.bind(this);
298
- if (this._source !== null) this._connectSource(this._source, audioContext);
299
- });
300
- }
301
- _onWorkletMessage(event) {
302
- const message = event.data;
303
- switch (message.type) {
304
- case "state":
305
- this._analysisTime = message.analysisTime ?? 0;
306
- this._analysisLatency = Math.max(0, (this._workletNode?.context.currentTime ?? this._analysisTime) - this._analysisTime);
307
- this._tempo = message.tempo ?? 0;
308
- this._beatPhase = message.beatPhase ?? 0;
309
- this._nextBeatTime = message.nextBeatTime ?? 0;
310
- this._nextDownbeatTime = message.nextDownbeatTime ?? 0;
311
- this._confidence = message.confidence ?? 0;
312
- this._phaseConfidence = message.phaseConfidence ?? 0;
313
- this._gridStability = message.gridStability ?? 0;
314
- this._tempoCandidates = Object.freeze(message.tempoCandidates ?? []);
315
- this._rms = message.rms ?? 0;
316
- this._onsetStrength = message.onsetStrength ?? 0;
317
- this._bandEnergy = message.bandEnergy ?? {
318
- low: 0,
319
- mid: 0,
320
- high: 0
321
- };
322
- this._barPosition = message.barPosition ?? 1;
323
- this._barLength = message.barLength ?? 4;
324
- this._timeSignature = message.timeSignature ?? {
325
- numerator: 4,
326
- denominator: 4
327
- };
328
- {
329
- const lookahead = message.lookahead ?? [];
330
- this._lookahead = Object.freeze(lookahead);
331
- if (lookahead.length > 0) this.onBeatPredicted.dispatch(lookahead[0]);
332
- }
333
- break;
334
- case "beat": {
335
- const bi = {
336
- audioTime: message.audioTime,
337
- tempo: message.tempo,
338
- confidence: message.confidence,
339
- beatPhase: message.beatPhase,
340
- energy: message.energy,
341
- isDownbeat: message.isDownbeat,
342
- beatInBar: message.beatInBar,
343
- status: message.status ?? "locked"
344
- };
345
- this.onBeat.dispatch(bi);
346
- if (bi.isDownbeat) this.onDownbeat.dispatch(bi);
347
- break;
348
- }
349
- case "tempoChange":
350
- this.onTempoChange.dispatch(message.newTempo, message.oldTempo);
351
- break;
352
- case "barStart": {
353
- const info = {
354
- audioTime: message.audioTime,
355
- tempo: message.tempo,
356
- confidence: message.confidence,
357
- barNumber: message.barNumber
358
- };
359
- this.onBarStart.dispatch(info);
360
- break;
361
- }
362
- }
363
- }
364
- _connectSource(source, audioContext) {
365
- if (!this._workletNode) return;
366
- const tap = this._resolveToAudioNode(source, audioContext);
367
- if (!tap) {
368
- this._deferConnectionViaBus(source);
369
- return;
370
- }
371
- this._tapSource = tap;
372
- tap.connect(this._workletNode, 0, 0);
373
- }
374
- _resolveToAudioNode(source, audioContext) {
375
- if (source === null) return null;
376
- if (typeof source.getTracks === "function") {
377
- if (this._streamSource) {
378
- this._streamSource.disconnect();
379
- this._streamSource = null;
380
- }
381
- const msNode = audioContext.createMediaStreamSource(source);
382
- this._streamSource = msNode;
383
- return msNode;
384
- }
385
- const asBus = source;
386
- if (typeof asBus.getOutputNode === "function") return asBus.getOutputNode();
387
- const asVoice = source;
388
- if ("output" in asVoice && asVoice.output) return asVoice.output;
389
- const asNode = source;
390
- if (typeof asNode.connect === "function" && typeof asNode.disconnect === "function") return source;
391
- return null;
392
- }
393
- _deferConnectionViaBus(source) {
394
- const asBus = source;
395
- if (typeof asBus.onceSetup === "function") {
396
- asBus.onceSetup(() => {
397
- if (this._source === source && this._workletNode && isAudioContextReady()) this._connectSource(source, getAudioContext());
398
- });
399
- return;
400
- }
401
- onAudioContextReady.once(() => {
402
- if (this._source === source && this._workletNode && isAudioContextReady()) this._connectSource(source, getAudioContext());
403
- });
404
- }
405
- _disconnectTap() {
406
- if (this._tapSource && this._workletNode) try {
407
- this._tapSource.disconnect(this._workletNode);
408
- } catch {}
409
- this._tapSource = null;
410
- if (this._streamSource) {
411
- this._streamSource.disconnect();
412
- this._streamSource = null;
413
- }
414
- }
415
- };
416
-
417
- //#endregion
418
- export { BeatDetector };
419
- //# sourceMappingURL=BeatDetector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BeatDetector.js","names":["beatDetectorWorkletSource","asStream"],"sources":["../../src/BeatDetector.ts"],"sourcesContent":["import { type AudioBus, getAudioContext, isAudioContextReady, onAudioContextReady, registerAudioWorkletProcessor, Signal, type Voice } from '@codexo/exojs';\n\nimport beatDetectorWorkletSource from './worklets/beat-detector.worklet.ts?worklet';\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport type BeatDetectorSource = AudioBus | Voice | MediaStream | AudioNode | null;\n\nexport interface BeatDetectorOptions {\n /** Minimum detectable BPM. Default 50. */\n minBpm?: number;\n /** Maximum detectable BPM. Default 300. */\n maxBpm?: number;\n /** FFT size for onset detection. Default 2048. */\n fftSize?: number;\n /** Hop size in samples between successive FFTs. Default 512. */\n hopSize?: number;\n /**\n * Short tempogram window (seconds) that reacts quickly to a genuine tempo\n * change. Default 2.5. The tracked tempo follows this FAST window only when it\n * disagrees with {@link stableTempoWindowSec} consistently over several\n * analysis hops, so a real DJ drift is tracked without making a steady tempo\n * nervous.\n */\n fastTempoWindowSec?: number;\n /**\n * Long tempogram window (seconds) that holds the tempo grid steady against\n * noise and octave ambiguity. Default 8. Should be ≥ {@link fastTempoWindowSec}\n * and large enough to hold ≳ 2 periods of the slowest tempo; it also sizes the\n * internal flux ring buffer.\n */\n stableTempoWindowSec?: number;\n /**\n * Hops between successive autocorrelation (tempogram) recomputations.\n * Default 15 (~160 ms at 48 kHz with the default 512-sample hop). Lower values\n * react faster to tempo changes at the cost of more CPU.\n */\n acfIntervalHops?: number;\n /**\n * Minimum warm-up (ms) before the first beat may be emitted. Default 400.\n * The detector starts hunting a tempo once this much analysis history exists\n * instead of waiting a full slowest-tempo period, so early {@link BeatInfo}\n * beats (tagged `status: 'provisional'`) arrive with low latency for visual\n * reactivity. A beat is promoted to `status: 'locked'` only once the tempo grid\n * is trustworthy (full analysis window + sustained on-grid tracking). Replaces\n * the former `settlingMs` (default 1500).\n */\n minSettlingMs?: number;\n /**\n * When true (default), early low-confidence beats are emitted tagged\n * `status: 'provisional'` (then promoted to `'locked'`) for snappy visual\n * reactivity. Set false to suppress provisional beats entirely - {@link onBeat}\n * then fires only for `'locked'` beats, matching the pre-provisional behaviour.\n */\n emitProvisionalBeats?: boolean;\n /** Number of mel filterbank bands. Default 24. */\n melBands?: number;\n /**\n * When true (default), the worklet runs parallel 3/4 and 4/4 posteriors and\n * switches active time signature via hysteresis. Set false to lock to 4/4.\n */\n enableTimeSignatureDetection?: boolean;\n /**\n * Optional initial source. Equivalent to constructing then assigning\n * `detector.source = value`; provided for ergonomic one-shot construction.\n * The setter remains usable for runtime source switches.\n */\n source?: BeatDetectorSource;\n /**\n * Half-life in seconds for the {@link BeatDetector.pulse} envelope.\n * Default 0.15 - `pulse` halves every 150ms after each beat.\n */\n pulseHalfLife?: number;\n /**\n * Half-life in seconds for the {@link BeatDetector.barPulse} envelope.\n * Default 0.3 - slower than beat pulse for downbeat-emphasized visuals.\n */\n barPulseHalfLife?: number;\n /**\n * Time window in seconds for {@link BeatDetector.justBeat}. Default 0.03\n * - true for the visual frame(s) within 30ms of a beat onset.\n */\n justBeatWindow?: number;\n}\n\nexport interface BeatInfo {\n /** audioContext.currentTime when the beat occurred. */\n audioTime: number;\n /** BPM at this beat. */\n tempo: number;\n /** Confidence 0..1. */\n confidence: number;\n /** Phase within beat (0 = start). */\n beatPhase: number;\n /** Novelty/onset strength at the beat. */\n energy: number;\n /** Is this beat the first in a bar? */\n isDownbeat: boolean;\n /** Beat position within the bar (1..N). */\n beatInBar: number;\n /**\n * Detection trust level:\n * - `'provisional'` - an early, low-latency beat emitted before the tempo grid\n * is fully settled. Good for visual reactivity (a \"blink\"); may be revised.\n * - `'locked'` - the tempo grid is settled and trustworthy. Safe for\n * sync-critical use. Each stable segment yields exactly one provisional→locked\n * transition.\n */\n status: 'provisional' | 'locked';\n}\n\nexport interface UpcomingBeat {\n audioTime: number;\n tempo: number;\n isDownbeat: boolean;\n beatInBar: number;\n}\n\nexport interface BarInfo {\n audioTime: number;\n tempo: number;\n confidence: number;\n /** Monotonically increasing bar counter since detector start. */\n barNumber: number;\n}\n\nexport interface TimeSignature {\n numerator: number;\n denominator: number;\n}\n\nexport interface TempoCandidate {\n bpm: number;\n /** Peak strength 0..1. */\n score: number;\n}\n\nexport interface BandEnergy {\n low: number;\n mid: number;\n high: number;\n}\n\nconst workletName = 'exojs-beat-detector';\n\n/**\n * Real-time tempo + beat tracker. Splits work between the audio-rendering\n * thread (an AudioWorklet that runs onset detection, tempogram analysis,\n * and parallel 3/4 and 4/4 posterior estimation) and the main thread (this\n * class - receives beats, fires Signals, handles configuration and source\n * routing).\n *\n * Accepts a wide range of {@link BeatDetectorSource}s - a bus, an individual\n * {@link Voice}, a raw MediaStream, or any AudioNode - and exposes a Signal\n * for each notable event:\n * - {@link BeatDetector.onBeat} - every detected beat\n * - {@link BeatDetector.onDownbeat} - first beat of each bar\n * - {@link BeatDetector.onBarStart} - bar boundary\n * - {@link BeatDetector.onTempoChange} - when the tracked BPM changes\n * - {@link BeatDetector.onBeatPredicted} - look-ahead schedule notice\n *\n * Early beats arrive with low latency tagged `status: 'provisional'` (after a\n * short `minSettlingMs` warm-up, default 400 ms) for snappy visual reactivity,\n * then promote to `status: 'locked'` once the tempo grid is trustworthy - a\n * single {@link BeatDetector.onBeat} signal carries both via {@link BeatInfo.status}.\n * Set `emitProvisionalBeats: false` to receive only locked beats. Time-signature\n * detection (3/4 vs 4/4) is on by default; lock to 4/4 by setting\n * `enableTimeSignatureDetection: false`.\n */\nexport class BeatDetector {\n // ---- Signals ----\n public readonly onBeat = new Signal<[BeatInfo]>();\n public readonly onTempoChange = new Signal<[number, number]>();\n public readonly onDownbeat = new Signal<[BeatInfo]>();\n public readonly onBarStart = new Signal<[BarInfo]>();\n public readonly onBeatPredicted = new Signal<[UpcomingBeat]>();\n\n // ---- Options ----\n // enableTimeSignatureDetection not in Required<> since it has a default; keep as full explicit type\n private readonly _options: Required<BeatDetectorOptions>;\n\n // ---- Audio plumbing ----\n private _workletNode: AudioWorkletNode | null = null;\n private _source: BeatDetectorSource = null;\n private _tapSource: AudioNode | null = null;\n private _streamSource: MediaStreamAudioSourceNode | null = null;\n private _ready: Promise<void> | null = null;\n private _pendingSourceSetup: ((ctx: AudioContext) => void) | null = null;\n private readonly _onAudioContextReady = (ctx: AudioContext): void => {\n onAudioContextReady.remove(this._onAudioContextReady);\n this._setup(ctx);\n };\n\n // ---- Cached state from worklet ----\n private _tempo = 0;\n private _beatPhase = 0;\n private _nextBeatTime = 0;\n private _confidence = 0;\n private _phaseConfidence = 0;\n private _gridStability = 0;\n private _analysisTime = 0;\n private _analysisLatency = 0;\n private _tempoCandidates: readonly TempoCandidate[] = [];\n private _rms = 0;\n private _onsetStrength = 0;\n private _bandEnergy: BandEnergy = { low: 0, mid: 0, high: 0 };\n private _barPosition = 1;\n private _barLength = 4;\n private _timeSignature: TimeSignature = { numerator: 4, denominator: 4 };\n private _nextDownbeatTime = 0;\n private _lookahead: readonly UpcomingBeat[] = Object.freeze([]);\n\n /**\n * Half-life in seconds for the {@link pulse} envelope. Mutable; default 0.15.\n * Smaller values give a snappier pulse, larger values a longer afterglow.\n */\n public pulseHalfLife: number;\n\n /** Half-life for the {@link barPulse} envelope. Mutable; default 0.3. */\n public barPulseHalfLife: number;\n\n /** Time window for {@link justBeat}. Mutable; default 0.03 (30ms). */\n public justBeatWindow: number;\n\n public constructor(options?: BeatDetectorOptions) {\n this._options = {\n minBpm: options?.minBpm ?? 50,\n maxBpm: options?.maxBpm ?? 300,\n fftSize: options?.fftSize ?? 2048,\n hopSize: options?.hopSize ?? 512,\n fastTempoWindowSec: options?.fastTempoWindowSec ?? 2.5,\n stableTempoWindowSec: options?.stableTempoWindowSec ?? 8,\n acfIntervalHops: options?.acfIntervalHops ?? 15,\n minSettlingMs: options?.minSettlingMs ?? 400,\n emitProvisionalBeats: options?.emitProvisionalBeats ?? true,\n melBands: options?.melBands ?? 24,\n enableTimeSignatureDetection: options?.enableTimeSignatureDetection ?? true,\n // Visual-state options aren't part of worklet config; cached in the public\n // fields below but kept in the Required<> shape for type completeness.\n source: options?.source ?? null,\n pulseHalfLife: options?.pulseHalfLife ?? 0.15,\n barPulseHalfLife: options?.barPulseHalfLife ?? 0.3,\n justBeatWindow: options?.justBeatWindow ?? 0.03,\n };\n\n this.pulseHalfLife = this._options.pulseHalfLife;\n this.barPulseHalfLife = this._options.barPulseHalfLife;\n this.justBeatWindow = this._options.justBeatWindow;\n\n if (isAudioContextReady()) {\n this._setup(getAudioContext());\n } else {\n onAudioContextReady.add(this._onAudioContextReady);\n }\n\n if (options?.source !== undefined && options.source !== null) {\n this.source = options.source;\n }\n }\n\n // -----------------------------------------------------------------------\n // Source setter (polymorphic tap)\n // -----------------------------------------------------------------------\n\n public get source(): BeatDetectorSource {\n return this._source;\n }\n\n public set source(value: BeatDetectorSource) {\n if (value === this._source) return;\n\n this._disconnectTap();\n this._source = value;\n\n if (value === null) return;\n\n if (isAudioContextReady()) {\n this._pendingSourceSetup = null;\n this._connectSource(value, getAudioContext());\n } else {\n if (this._pendingSourceSetup !== null) {\n onAudioContextReady.remove(this._pendingSourceSetup);\n }\n\n const handler = (ctx: AudioContext): void => {\n onAudioContextReady.remove(handler);\n this._pendingSourceSetup = null;\n this._connectSource(value, ctx);\n };\n\n this._pendingSourceSetup = handler;\n onAudioContextReady.add(handler);\n }\n }\n\n // -----------------------------------------------------------------------\n // Ready promise\n // -----------------------------------------------------------------------\n\n public get ready(): Promise<void> {\n return this._ready ?? Promise.resolve();\n }\n\n // -----------------------------------------------------------------------\n // Stage 1 state accessors\n // -----------------------------------------------------------------------\n\n public get tempo(): number {\n return this._tempo;\n }\n public get beatPhase(): number {\n return this._beatPhase;\n }\n public get nextBeatTime(): number {\n return this._nextBeatTime;\n }\n public get confidence(): number {\n return this._confidence;\n }\n\n /**\n * How well recent onsets support the beat grid's phase, 0 to 1, or 0 before\n * the grid locks.\n *\n * Distinct from {@link confidence}, which reports how sure the detector is of\n * the tempo. A metronomic loop at a wrong-by-an-octave tempo reads high\n * confidence and high phase confidence; a rubato passage at a known tempo\n * reads high confidence and low phase confidence. Gate anything that must\n * land exactly on the beat - a scored hit, a quantised trigger - on this\n * rather than on {@link confidence}.\n */\n public get phaseConfidence(): number {\n return this._phaseConfidence;\n }\n\n public get gridStability(): number {\n return this._gridStability;\n }\n\n /**\n * The `AudioContext.currentTime` of the newest sample the current state\n * describes. 0 until the first state message arrives.\n *\n * Every timestamp this detector reports - this one, {@link BeatInfo.audioTime},\n * {@link nextBeatTime}, {@link lookahead} - is on the audio context's clock,\n * so `AudioOutputClock` converts them to the `performance.now()` timeline\n * without further correction.\n */\n public get analysisTime(): number {\n return this._analysisTime;\n }\n\n /**\n * Seconds between {@link analysisTime} and the moment the main thread\n * received that state, measured rather than assumed.\n *\n * Covers the analysis hop and the worklet-to-main-thread delivery together,\n * and is quantised to the context's render-quantum boundary, so treat it as\n * a budget figure rather than an exact age. It says nothing about the output\n * path: what a listener hears lags the analysed audio by the output latency\n * on top, which `AudioOutputClock` reports.\n */\n public get analysisLatency(): number {\n return this._analysisLatency;\n }\n public get rms(): number {\n return this._rms;\n }\n public get onsetStrength(): number {\n return this._onsetStrength;\n }\n public get bandEnergy(): BandEnergy {\n return this._bandEnergy;\n }\n\n public get tempoCandidates(): readonly TempoCandidate[] {\n return this._tempoCandidates;\n }\n\n // -----------------------------------------------------------------------\n // Stage 2 state accessors\n // -----------------------------------------------------------------------\n\n public get barPosition(): number {\n return this._barPosition;\n }\n public get barLength(): number {\n return this._barLength;\n }\n public get timeSignature(): TimeSignature {\n return this._timeSignature;\n }\n public get nextDownbeatTime(): number {\n return this._nextDownbeatTime;\n }\n\n public get lookahead(): readonly UpcomingBeat[] {\n return this._lookahead;\n }\n\n // -----------------------------------------------------------------------\n // Visual derived state - pure getters for per-frame polling\n // -----------------------------------------------------------------------\n\n /**\n * Seconds elapsed since the most recent beat, derived from {@link beatPhase}\n * and {@link tempo}. Returns 0 when the detector hasn't locked yet.\n */\n public get secondsSinceLastBeat(): number {\n if (this._tempo === 0) return 0;\n return this._beatPhase * (60 / this._tempo);\n }\n\n /**\n * 0..1 envelope, peaks at 1.0 the moment a beat fires and halves every\n * {@link pulseHalfLife} seconds. Drives \"pulse on the beat\" visuals\n * with a single multiplication: `sprite.scale = 1 + clock.pulse * 0.3`.\n */\n public get pulse(): number {\n if (this._tempo === 0) return 0;\n return Math.pow(0.5, this.secondsSinceLastBeat / this.pulseHalfLife);\n }\n\n /**\n * Like {@link pulse} but resets on downbeats and decays per\n * {@link barPulseHalfLife}. Useful for emphasizing the first beat of\n * each bar (e.g. brighter flash on \"1\" vs \"2,3,4\").\n */\n public get barPulse(): number {\n if (this._tempo === 0 || this._barLength === 0) return 0;\n const secondsPerBeat = 60 / this._tempo;\n const lastDownbeat = this._nextDownbeatTime - this._barLength * secondsPerBeat;\n const elapsed = Math.max(0, getAudioContext().currentTime - lastDownbeat);\n return Math.pow(0.5, elapsed / this.barPulseHalfLife);\n }\n\n /**\n * True for the visual frame(s) within {@link justBeatWindow} seconds of\n * a beat onset. Use for one-shot triggers (strobe flash, particle burst,\n * sample retrigger). Default window 30ms covers a typical 60fps frame.\n */\n public get justBeat(): boolean {\n return this._tempo > 0 && this.secondsSinceLastBeat < this.justBeatWindow;\n }\n\n /**\n * Phase 0..1 within a subdivision of the current beat. `division` is the\n * number of subdivisions per beat: 2 for 8th notes, 4 for 16th notes,\n * 3 for triplets. Use to drive sub-beat-resolution effects:\n *\n * const sixteenth = clock.subdivisionPhase(4);\n * if (sixteenth < 0.05) flash();\n */\n public subdivisionPhase(division: number): number {\n if (!Number.isFinite(division) || division <= 0) return 0;\n return (this._beatPhase * division) % 1;\n }\n\n // -----------------------------------------------------------------------\n // Lifecycle\n // -----------------------------------------------------------------------\n\n public destroy(): void {\n onAudioContextReady.remove(this._onAudioContextReady);\n\n if (this._pendingSourceSetup !== null) {\n onAudioContextReady.remove(this._pendingSourceSetup);\n this._pendingSourceSetup = null;\n }\n this._disconnectTap();\n this._workletNode?.disconnect();\n this._workletNode = null;\n this._ready = null;\n this.onBeat.clear();\n this.onTempoChange.clear();\n this.onDownbeat.clear();\n this.onBarStart.clear();\n this.onBeatPredicted.clear();\n }\n\n // -----------------------------------------------------------------------\n // Private helpers - setup\n // -----------------------------------------------------------------------\n\n private _setup(audioContext: AudioContext): void {\n const opts = this._options;\n this._ready = registerAudioWorkletProcessor(audioContext, workletName, beatDetectorWorkletSource).then(() => {\n const node = new AudioWorkletNode(audioContext, workletName, {\n numberOfInputs: 1,\n numberOfOutputs: 0,\n processorOptions: {\n fftSize: opts.fftSize,\n hopSize: opts.hopSize,\n minBpm: opts.minBpm,\n maxBpm: opts.maxBpm,\n melBands: opts.melBands,\n minSettlingMs: opts.minSettlingMs,\n emitProvisionalBeats: opts.emitProvisionalBeats,\n fastTempoWindowSec: opts.fastTempoWindowSec,\n stableTempoWindowSec: opts.stableTempoWindowSec,\n acfIntervalHops: opts.acfIntervalHops,\n enableTimeSignatureDetection: opts.enableTimeSignatureDetection,\n },\n });\n\n this._workletNode = node;\n node.port.onmessage = this._onWorkletMessage.bind(this);\n\n // If a source was set before worklet was ready, connect it now.\n if (this._source !== null) {\n this._connectSource(this._source, audioContext);\n }\n });\n }\n\n private _onWorkletMessage(event: MessageEvent): void {\n const message = event.data as Record<string, unknown>;\n switch (message.type) {\n case 'state':\n this._analysisTime = (message.analysisTime as number) ?? 0;\n this._analysisLatency = Math.max(0, (this._workletNode?.context.currentTime ?? this._analysisTime) - this._analysisTime);\n this._tempo = (message.tempo as number) ?? 0;\n this._beatPhase = (message.beatPhase as number) ?? 0;\n this._nextBeatTime = (message.nextBeatTime as number) ?? 0;\n this._nextDownbeatTime = (message.nextDownbeatTime as number) ?? 0;\n this._confidence = (message.confidence as number) ?? 0;\n this._phaseConfidence = (message.phaseConfidence as number) ?? 0;\n this._gridStability = (message.gridStability as number) ?? 0;\n this._tempoCandidates = Object.freeze((message.tempoCandidates as TempoCandidate[]) ?? []);\n this._rms = (message.rms as number) ?? 0;\n this._onsetStrength = (message.onsetStrength as number) ?? 0;\n this._bandEnergy = (message.bandEnergy as BandEnergy) ?? { low: 0, mid: 0, high: 0 };\n this._barPosition = (message.barPosition as number) ?? 1;\n this._barLength = (message.barLength as number) ?? 4;\n this._timeSignature = (message.timeSignature as TimeSignature) ?? { numerator: 4, denominator: 4 };\n {\n const lookahead = (message.lookahead as UpcomingBeat[]) ?? [];\n this._lookahead = Object.freeze(lookahead);\n if (lookahead.length > 0) {\n this.onBeatPredicted.dispatch(lookahead[0]!);\n }\n }\n break;\n\n case 'beat': {\n const bi: BeatInfo = {\n audioTime: message.audioTime as number,\n tempo: message.tempo as number,\n confidence: message.confidence as number,\n beatPhase: message.beatPhase as number,\n energy: message.energy as number,\n isDownbeat: message.isDownbeat as boolean,\n beatInBar: message.beatInBar as number,\n status: (message.status as 'provisional' | 'locked' | undefined) ?? 'locked',\n };\n this.onBeat.dispatch(bi);\n if (bi.isDownbeat) this.onDownbeat.dispatch(bi);\n break;\n }\n\n case 'tempoChange':\n this.onTempoChange.dispatch(message.newTempo as number, message.oldTempo as number);\n break;\n\n case 'barStart': {\n const info: BarInfo = {\n audioTime: message.audioTime as number,\n tempo: message.tempo as number,\n confidence: message.confidence as number,\n barNumber: message.barNumber as number,\n };\n this.onBarStart.dispatch(info);\n break;\n }\n }\n }\n\n // -----------------------------------------------------------------------\n // Private helpers - source tap\n // -----------------------------------------------------------------------\n\n private _connectSource(source: BeatDetectorSource, audioContext: AudioContext): void {\n if (!this._workletNode) return;\n\n const tap = this._resolveToAudioNode(source, audioContext);\n if (!tap) {\n this._deferConnectionViaBus(source);\n return;\n }\n\n this._tapSource = tap;\n tap.connect(this._workletNode, 0, 0);\n }\n\n private _resolveToAudioNode(source: BeatDetectorSource, audioContext: AudioContext): AudioNode | null {\n if (source === null) return null;\n\n // MediaStream - duck-type via getTracks\n const asStream = source as Partial<{ getTracks: unknown }>;\n if (typeof asStream.getTracks === 'function') {\n if (this._streamSource) {\n this._streamSource.disconnect();\n this._streamSource = null;\n }\n const msNode = audioContext.createMediaStreamSource(source as MediaStream);\n this._streamSource = msNode;\n return msNode;\n }\n\n // AudioBus - has getOutputNode (checked before raw AudioNode)\n const asBus = source as Partial<{ getOutputNode: () => AudioNode | null }>;\n if (typeof asBus.getOutputNode === 'function') {\n return asBus.getOutputNode();\n }\n\n // Voice - tap its output node\n const asVoice = source as Partial<{ output: AudioNode }>;\n if ('output' in asVoice && asVoice.output) {\n return asVoice.output;\n }\n\n // Raw AudioNode - duck-type: has connect & disconnect\n const asNode = source as Partial<{ connect: unknown; disconnect: unknown }>;\n if (typeof asNode.connect === 'function' && typeof asNode.disconnect === 'function') {\n return source as unknown as AudioNode;\n }\n\n return null;\n }\n\n private _deferConnectionViaBus(source: BeatDetectorSource): void {\n const asBus = source as Partial<{ onceSetup: (callback: () => void) => void }>;\n if (typeof asBus.onceSetup === 'function') {\n asBus.onceSetup(() => {\n if (this._source === source && this._workletNode && isAudioContextReady()) {\n this._connectSource(source, getAudioContext());\n }\n });\n return;\n }\n\n onAudioContextReady.once(() => {\n if (this._source === source && this._workletNode && isAudioContextReady()) {\n this._connectSource(source, getAudioContext());\n }\n });\n }\n\n private _disconnectTap(): void {\n if (this._tapSource && this._workletNode) {\n try {\n this._tapSource.disconnect(this._workletNode);\n } catch {\n // Ignore\n }\n }\n this._tapSource = null;\n\n if (this._streamSource) {\n this._streamSource.disconnect();\n this._streamSource = null;\n }\n }\n}\n"],"mappings":";;;;AAiJA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;AA0BpB,IAAa,eAAb,MAA0B;CAExB,AAAgB,SAAS,IAAI,OAAmB;CAChD,AAAgB,gBAAgB,IAAI,OAAyB;CAC7D,AAAgB,aAAa,IAAI,OAAmB;CACpD,AAAgB,aAAa,IAAI,OAAkB;CACnD,AAAgB,kBAAkB,IAAI,OAAuB;CAI7D,AAAiB;CAGjB,AAAQ,eAAwC;CAChD,AAAQ,UAA8B;CACtC,AAAQ,aAA+B;CACvC,AAAQ,gBAAmD;CAC3D,AAAQ,SAA+B;CACvC,AAAQ,sBAA4D;CACpE,AAAiB,wBAAwB,QAA4B;EACnE,oBAAoB,OAAO,KAAK,oBAAoB;EACpD,KAAK,OAAO,GAAG;CACjB;CAGA,AAAQ,SAAS;CACjB,AAAQ,aAAa;CACrB,AAAQ,gBAAgB;CACxB,AAAQ,cAAc;CACtB,AAAQ,mBAAmB;CAC3B,AAAQ,iBAAiB;CACzB,AAAQ,gBAAgB;CACxB,AAAQ,mBAAmB;CAC3B,AAAQ,mBAA8C,CAAC;CACvD,AAAQ,OAAO;CACf,AAAQ,iBAAiB;CACzB,AAAQ,cA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vE,OAAO;EAGT,OAAO;CACT;CAEA,AAAQ,uBAAuB,QAAkC;EAC/D,MAAM,QAAQ;EACd,IAAI,OAAO,MAAM,cAAc,YAAY;GACzC,MAAM,gBAAgB;IACpB,IAAI,KAAK,YAAY,UAAU,KAAK,gBAAgB,oBAAoB,GACtE,KAAK,eAAe,QAAQ,gBAAgB,CAAC;GAEjD,CAAC;GACD;EACF;EAEA,oBAAoB,WAAW;GAC7B,IAAI,KAAK,YAAY,UAAU,KAAK,gBAAgB,oBAAoB,GACtE,KAAK,eAAe,QAAQ,gBAAgB,CAAC;EAEjD,CAAC;CACH;CAEA,AAAQ,iBAAuB;EAC7B,IAAI,KAAK,cAAc,KAAK,cAC1B,IAAI;GACF,KAAK,WAAW,WAAW,KAAK,YAAY;EAC9C,QAAQ,CAER;EAEF,KAAK,aAAa;EAElB,IAAI,KAAK,eAAe;GACtB,KAAK,cAAc,WAAW;GAC9B,KAAK,gBAAgB;EACvB;CACF;AACF"}
@@ -1,127 +0,0 @@
1
- import { type AudioBus, type Seconds, Signal } from '@codexo/exojs';
2
- export interface PcmStreamSourceOptions {
3
- /** Fixed channel count. PCM is not remixed or resampled by this source. */
4
- channels: 1 | 2;
5
- /** Maximum outstanding frames, including messages in transit. Integer 1..1048576; default 8192. This is a capacity, not a target latency. */
6
- capacityFrames?: number;
7
- /** Destination bus. Default `null` leaves the output disconnected. Ownership stays with the caller. */
8
- bus?: AudioBus | null;
9
- }
10
- export type PcmStreamState = 'loading' | 'ready' | 'running' | 'closing' | 'closed' | 'failed' | 'destroyed';
11
- /**
12
- * A bounded, externally fed Float32 PCM source at the shared AudioContext's
13
- * sample rate. Lives in `@codexo/exojs-audio-fx`; no extension registration is
14
- * required. Feed a bus or connect {@link output} to an analysis tap.
15
- *
16
- * Await {@link ready}, enqueue a caller-chosen amount of audio, then call
17
- * {@link start}. The worklet consumes FIFO samples without waiting for the
18
- * producer. An empty running queue emits silence; later blocks resume at the
19
- * next available render quantum, without catching up or skipping samples.
20
- * Browser suspension freezes the audio clock and playback, but writes remain
21
- * bounded. Readiness does not unlock browser autoplay.
22
- *
23
- * Input arrays are copied synchronously and never detached. The private copy
24
- * is transferred without requiring cross-origin isolation. Values must be
25
- * finite; nominal full scale is -1..1, with no clipping or normalization here.
26
- * Resampling, producer timestamps and audiovisual lookahead belong to callers.
27
- *
28
- * Own and destroy the source separately from its bus, for example with a scene
29
- * DestroyScope. Destroying an AudioSystem or bus does not destroy this source.
30
- */
31
- export declare class PcmStreamSource {
32
- readonly channels: 1 | 2;
33
- readonly capacityFrames: number;
34
- readonly sampleRate: number;
35
- /** Resolves after module loading, even while audio is suspended. Rejects on loading failure or destruction during loading (`AbortError`). */
36
- readonly ready: Promise<void>;
37
- /** Fires once after close has drained, not on destroy or failure. */
38
- readonly onEnd: Signal<[]>;
39
- /** Reports module loading, processor or context closure failures. The source is terminal afterwards. */
40
- readonly onError: Signal<[Error]>;
41
- /** Stable source tap. Bus routing changes preserve caller-created connections; terminal cleanup disconnects it. */
42
- readonly output: GainNode;
43
- private readonly _context;
44
- private _state;
45
- private _node;
46
- private _bus;
47
- private _busNode;
48
- private _cancelBusSetup;
49
- private _submittedFrames;
50
- private _highWaterFrames;
51
- private _releasedFrames;
52
- private _playedFrames;
53
- private _underrunFrames;
54
- private _underruns;
55
- private _overflowCount;
56
- private _droppedFrames;
57
- private _clearing;
58
- private _resolveReady;
59
- private _rejectReady;
60
- private readonly _onContextState;
61
- constructor(options: PcmStreamSourceOptions);
62
- get state(): PcmStreamState;
63
- /** Conservative occupancy: submitted frames minus acknowledged consumed/discarded frames. May lag playback while messages are in flight. */
64
- get bufferedFrames(): number;
65
- /** Queue occupancy in seconds, excluding output-device latency. */
66
- get bufferedSeconds(): Seconds;
67
- /** Lifetime accepted frames. Refused, invalid and empty writes do not increase this count; clear and teardown preserve it. */
68
- get enqueuedFrames(): number;
69
- /** Lifetime maximum bufferedFrames after an accepted write, including transport and unacknowledged consumption. Never exceeds capacityFrames; clear and teardown preserve it. */
70
- get highWaterFrames(): number;
71
- /** True until the worklet acknowledges clear; writes are refused during this interval. */
72
- get clearing(): boolean;
73
- /** Lifetime frames actually rendered from PCM, as of the latest worklet report. */
74
- get playedFrames(): number;
75
- /** Lifetime silent frames caused by starvation after start; excludes idle, suspended and drained time. */
76
- get underrunFrames(): number;
77
- /** Lifetime contiguous starvation episodes, as of the latest report. */
78
- get underruns(): number;
79
- /** Lifetime blocks refused for insufficient capacity. Other refused writes are not overflow. */
80
- get overflowCount(): number;
81
- /** Lifetime frames refused for insufficient capacity; not frames discarded by clear or destroy. */
82
- get droppedFrames(): number;
83
- get bus(): AudioBus | null;
84
- /** Reroute to a bus input, or disconnect that route with `null`. Does not take ownership of the bus or its effects. */
85
- set bus(bus: AudioBus | null);
86
- /**
87
- * Begin once, no earlier than `time` in audio-context seconds (default now).
88
- * Sample positions round up to the next audio frame; a past time starts at
89
- * the next available quantum. Returns false unless ready and not yet started.
90
- */
91
- start(time?: number): boolean;
92
- /**
93
- * Copy equal-length mono/stereo channel arrays in FIFO order. Returns false
94
- * before ready, during clear, after close/failure/destroy, or on overflow.
95
- * Overflow rejects the entire block before copying. Empty blocks succeed
96
- * without sending a message. Invalid layout or nonfinite samples throw.
97
- */
98
- enqueuePlanar(channels: readonly Float32Array[]): boolean;
99
- /** Copy interleaved frames (L,R,L,R for stereo). Same acceptance and ownership contract as {@link enqueuePlanar}. */
100
- enqueueInterleaved(data: Float32Array): boolean;
101
- /**
102
- * Discard queued PCM once the worklet receives the command, retaining the
103
- * start schedule and lifetime counters. Coalesces while pending and refuses
104
- * new writes until acknowledged. No-op while loading or after close.
105
- */
106
- clear(): void;
107
- /**
108
- * Refuse further writes and drain. If not started, begin draining immediately;
109
- * otherwise preserve the scheduled start. Empty tails do not count as
110
- * underruns. Completes only when the context processes audio; use destroy for
111
- * immediate cancellation while suspended. Idempotent and terminal.
112
- */
113
- close(): void;
114
- /** Stop immediately, discard pending PCM, detach routes and release the port. Idempotent; never destroys the bus or shared context. */
115
- destroy(): void;
116
- private get _terminal();
117
- private get _writable();
118
- private _admit;
119
- private _validateSamples;
120
- private _submit;
121
- private _load;
122
- private _receive;
123
- private _fail;
124
- private _disconnectBus;
125
- private _dispose;
126
- }
127
- //# sourceMappingURL=PcmStreamSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PcmStreamSource.d.ts","sourceRoot":"","sources":["../../src/PcmStreamSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAkD,KAAK,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIpH,MAAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,6IAA6I;IAC7I,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uGAAuG;IACvG,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAU7G;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAe;IAC1B,SAAgB,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,6IAA6I;IAC7I,SAAgB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,qEAAqE;IACrE,SAAgB,KAAK,aAAgB;IACrC,wGAAwG;IACxG,SAAgB,OAAO,kBAAyB;IAChD,mHAAmH;IACnH,SAAgB,MAAM,EAAE,QAAQ,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC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