alpha2 0.4.5 → 0.5.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.
- package/README.md +5 -4
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/abort.d.ts +12 -0
- package/dist/abort.js +48 -0
- package/dist/active-clock.d.ts +35 -0
- package/dist/active-clock.js +99 -0
- package/dist/assets.d.ts +28 -22
- package/dist/assets.js +8 -12
- package/dist/audio-layout.d.ts +52 -74
- package/dist/audio-layout.js +114 -148
- package/dist/audio-timeline.d.ts +89 -117
- package/dist/audio-timeline.js +102 -118
- package/dist/audio-worker.d.ts +12 -21
- package/dist/audio-worker.js +8 -13
- package/dist/audio-worklet-processor.js +45 -58
- package/dist/audio-worklet.d.ts +45 -76
- package/dist/audio-worklet.js +44 -79
- package/dist/audio.d.ts +15 -23
- package/dist/audio.js +9 -13
- package/dist/builder.d.ts +45 -63
- package/dist/builder.js +49 -45
- package/dist/capabilities.d.ts +99 -16
- package/dist/capabilities.js +2 -2
- package/dist/captions.d.ts +45 -22
- package/dist/captions.js +60 -15
- package/dist/chroma-siting.d.ts +24 -41
- package/dist/chroma-siting.js +38 -71
- package/dist/containers.d.ts +41 -30
- package/dist/containers.js +59 -27
- package/dist/decoder-fallback.d.ts +13 -0
- package/dist/decoder-fallback.js +38 -0
- package/dist/decoder-order.d.ts +24 -39
- package/dist/decoder-order.js +28 -42
- package/dist/edit.d.ts +77 -154
- package/dist/edit.js +98 -180
- package/dist/effects.d.ts +109 -173
- package/dist/effects.js +7 -9
- package/dist/export-destination.d.ts +25 -41
- package/dist/export-destination.js +20 -32
- package/dist/export-failure.d.ts +34 -59
- package/dist/export-failure.js +54 -48
- package/dist/export-metrics.d.ts +116 -0
- package/dist/export-metrics.js +74 -0
- package/dist/export-retry.d.ts +46 -29
- package/dist/export-retry.js +86 -51
- package/dist/exporter.d.ts +67 -116
- package/dist/exporter.js +133 -133
- package/dist/extensions.d.ts +69 -115
- package/dist/extensions.js +55 -82
- package/dist/frame-intake.d.ts +92 -0
- package/dist/frame-intake.js +114 -0
- package/dist/frame-supply.d.ts +98 -157
- package/dist/frame-supply.js +191 -162
- package/dist/generated/project-schema.d.ts +742 -464
- package/dist/generated/project-schema.js +63 -2
- package/dist/generated/project-shape.js +663 -118
- package/dist/geometry.d.ts +28 -34
- package/dist/geometry.js +18 -23
- package/dist/gpu-recovery.d.ts +92 -0
- package/dist/gpu-recovery.js +135 -0
- package/dist/hdr-frames.d.ts +88 -62
- package/dist/hdr-frames.js +123 -46
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/json-text.d.ts +13 -23
- package/dist/json-text.js +10 -20
- package/dist/layout-values.d.ts +14 -22
- package/dist/layout-values.js +18 -21
- package/dist/layout.d.ts +55 -55
- package/dist/layout.js +37 -36
- package/dist/loudness.d.ts +27 -32
- package/dist/loudness.js +19 -23
- package/dist/media.d.ts +85 -237
- package/dist/media.js +133 -287
- package/dist/mediabunny.d.ts +173 -237
- package/dist/mediabunny.js +943 -518
- package/dist/physical-frames.d.ts +5 -17
- package/dist/physical-frames.js +4 -11
- package/dist/player.d.ts +56 -47
- package/dist/player.js +155 -40
- package/dist/presented-frames.d.ts +2 -7
- package/dist/presented-frames.js +3 -8
- package/dist/project.d.ts +83 -110
- package/dist/project.js +421 -447
- package/dist/rate-control.d.ts +9 -23
- package/dist/rate-control.js +7 -18
- package/dist/renderer-choice.d.ts +41 -0
- package/dist/renderer-choice.js +82 -0
- package/dist/repacked-bytes.d.ts +0 -2
- package/dist/repacked-bytes.js +2 -5
- package/dist/robustness.d.ts +25 -37
- package/dist/robustness.js +71 -54
- package/dist/sha256.d.ts +5 -13
- package/dist/sha256.js +9 -24
- package/dist/text.d.ts +106 -63
- package/dist/text.js +44 -69
- package/dist/video-frames.d.ts +7 -25
- package/dist/video-frames.js +12 -29
- package/dist/waveform.d.ts +5 -11
- package/dist/waveform.js +4 -9
- package/dist/worker-error.d.ts +5 -20
- package/dist/worker-error.js +8 -25
- package/dist/worker.d.ts +82 -92
- package/dist/worker.js +239 -144
- package/package.json +26 -2
- package/wasm/alpha2_audio_worklet.wasm +0 -0
- package/wasm/alpha2_extensions.d.ts +26 -47
- package/wasm/alpha2_extensions.js +26 -47
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_wasm.d.ts +487 -543
- package/wasm/alpha2_wasm.js +669 -572
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +20 -8
- package/wasm/rust-crate-licenses.md +2 -2
- package/wasm/snippets/{alpha2-wasm-57b04ecc6db57e1f → alpha2-wasm-1313375d424845c0}/inline1.js +1 -0
- package/wasm/snippets/alpha2-wasm-1313375d424845c0/inline2.js +82 -0
- package/wasm/snippets/alpha2-wasm-57b04ecc6db57e1f/inline2.js +0 -52
- /package/wasm/snippets/{alpha2-wasm-57b04ecc6db57e1f → alpha2-wasm-1313375d424845c0}/inline0.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-57b04ecc6db57e1f → alpha2-wasm-1313375d424845c0}/inline3.js +0 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Must match `MAX_FRAMES` in the DSP module. */
|
|
2
2
|
const MODULE_MAX_FRAMES = 4096;
|
|
3
|
-
/** The render quantum of every context that cannot choose another. */
|
|
4
3
|
const DEFAULT_QUANTUM = 128;
|
|
5
4
|
/**
|
|
6
|
-
* Frames per module call: the scope's render quantum
|
|
7
|
-
*
|
|
8
|
-
* into calls of this size.
|
|
5
|
+
* Frames per module call: the scope's render quantum when the module can take it whole, else the
|
|
6
|
+
* default quantum. `process` splits longer quanta into calls of this size.
|
|
9
7
|
*/
|
|
10
8
|
function moduleFrames() {
|
|
11
9
|
const quantum = globalThis
|
|
@@ -17,7 +15,7 @@ function moduleFrames() {
|
|
|
17
15
|
? quantum
|
|
18
16
|
: DEFAULT_QUANTUM;
|
|
19
17
|
}
|
|
20
|
-
/**
|
|
18
|
+
/** Worklet scopes lack `TextDecoder`. */
|
|
21
19
|
function decodeUtf8(bytes) {
|
|
22
20
|
let text = "";
|
|
23
21
|
for (let index = 0; index < bytes.length;) {
|
|
@@ -32,11 +30,8 @@ function decodeUtf8(bytes) {
|
|
|
32
30
|
return text;
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
|
-
* Reader half of the
|
|
36
|
-
*
|
|
37
|
-
* The index arithmetic is inlined here because a worklet module cannot rely on bundler-resolved
|
|
38
|
-
* imports. `AudioRingBuffer` in `alpha2/audio-timeline` is the writer half and the tested reference
|
|
39
|
-
* for this layout.
|
|
33
|
+
* Reader half of the shared audio ring. Inlined because a worklet module cannot rely on bundler
|
|
34
|
+
* imports; `AudioRingBuffer` in `alpha2/audio-timeline` is the writer and the tested reference.
|
|
40
35
|
*/
|
|
41
36
|
class RingReader {
|
|
42
37
|
#control;
|
|
@@ -54,8 +49,8 @@ class RingReader {
|
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
/**
|
|
57
|
-
* Fills
|
|
58
|
-
*
|
|
52
|
+
* Fills `frames` samples of each target and returns how many came from the ring. Channels fold
|
|
53
|
+
* as in `#readInput`.
|
|
59
54
|
*/
|
|
60
55
|
read(targets, frames) {
|
|
61
56
|
// Slots: 0 read, 1 write, 2 clear target, 3 clear epoch, 4 cleared epoch. A clear is the
|
|
@@ -96,7 +91,6 @@ class RingReader {
|
|
|
96
91
|
return produced;
|
|
97
92
|
}
|
|
98
93
|
}
|
|
99
|
-
/** No input connected: WebAudio passes no channels. */
|
|
100
94
|
const NO_CHANNELS = Object.freeze([]);
|
|
101
95
|
class Alpha2Processor extends AudioWorkletProcessor {
|
|
102
96
|
#exports;
|
|
@@ -107,16 +101,17 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
107
101
|
#channels = 0;
|
|
108
102
|
#ring;
|
|
109
103
|
#underruns = 0;
|
|
104
|
+
#firstReadReported = false;
|
|
110
105
|
#shapeReported = false;
|
|
111
106
|
#views = [];
|
|
112
107
|
// Once set, `process` returns false so the audio thread retires the node.
|
|
113
108
|
#disposed = false;
|
|
114
|
-
// The master chain is the identity, so
|
|
109
|
+
// The master chain is the identity, so input bypasses the module.
|
|
115
110
|
#transparent = false;
|
|
116
|
-
//
|
|
111
|
+
// Latency in samples as last posted to the host.
|
|
117
112
|
#latency = 0;
|
|
118
|
-
//
|
|
119
|
-
//
|
|
113
|
+
// Module buffer for project-rate ring samples and its per-channel stride; 0 when no rate
|
|
114
|
+
// conversion is needed.
|
|
120
115
|
#sourcePointer = 0;
|
|
121
116
|
#sourceFrames = 0;
|
|
122
117
|
#sourceViews;
|
|
@@ -143,9 +138,8 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
143
138
|
catch (thrown) {
|
|
144
139
|
error = thrown instanceof Error ? thrown.message : String(thrown);
|
|
145
140
|
}
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
// an error.
|
|
141
|
+
// Posted after any `alpha2-latency` the request caused. Without an id, a refusal is an
|
|
142
|
+
// error.
|
|
149
143
|
if (message.id !== undefined)
|
|
150
144
|
this.port.postMessage(error === undefined
|
|
151
145
|
? { type: "alpha2-applied", id: message.id }
|
|
@@ -156,10 +150,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
156
150
|
};
|
|
157
151
|
this.port.postMessage({ type: "alpha2-stage", stage: "processor-created" });
|
|
158
152
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Starts the module for `channels` at the context's rate. A ring carrying `sourceRate` (the
|
|
161
|
-
* project's) is converted to the context's rate when the two differ.
|
|
162
|
-
*/
|
|
153
|
+
/** Starts the module; a ring at another `sourceRate` is converted to the context's rate. */
|
|
163
154
|
async #initialize(wasm, channels, sourceRate) {
|
|
164
155
|
try {
|
|
165
156
|
this.port.postMessage({
|
|
@@ -167,7 +158,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
167
158
|
stage: "wasm-instantiating",
|
|
168
159
|
});
|
|
169
160
|
const instance = (await WebAssembly.instantiate(wasm, {})).instance;
|
|
170
|
-
// Disposed
|
|
161
|
+
// Disposed during compilation.
|
|
171
162
|
if (this.#disposed)
|
|
172
163
|
return;
|
|
173
164
|
this.port.postMessage({
|
|
@@ -217,24 +208,20 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
217
208
|
this.#views = [];
|
|
218
209
|
this.#sourceViews = undefined;
|
|
219
210
|
}
|
|
220
|
-
/** The message the module recorded for its last panic, if any. */
|
|
221
211
|
#panicMessage(exports) {
|
|
222
212
|
const length = exports.alpha2_worklet_panic_length();
|
|
223
213
|
if (length === 0)
|
|
224
214
|
return undefined;
|
|
225
215
|
return decodeUtf8(new Uint8Array(exports.memory.buffer, exports.alpha2_worklet_panic_message(), length));
|
|
226
216
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Applies a ring, master-chain or reset message. Returns why it could not, or undefined once it
|
|
229
|
-
* is in place.
|
|
230
|
-
*/
|
|
217
|
+
/** Applies a ring, master-chain or reset message. Returns an error message on failure. */
|
|
231
218
|
#apply(message) {
|
|
232
219
|
if (message.type === "alpha2-ring") {
|
|
233
|
-
// Without a ring the node processes
|
|
220
|
+
// Without a ring the node processes its WebAudio input.
|
|
234
221
|
this.#ring =
|
|
235
222
|
message.ring === undefined ? undefined : new RingReader(message.ring);
|
|
236
223
|
this.#underruns = 0;
|
|
237
|
-
//
|
|
224
|
+
// Rate conversion latency applies only to ring input.
|
|
238
225
|
this.#reportLatency();
|
|
239
226
|
return undefined;
|
|
240
227
|
}
|
|
@@ -248,7 +235,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
248
235
|
this.#refreshTransparency();
|
|
249
236
|
return undefined;
|
|
250
237
|
}
|
|
251
|
-
/** Installs a master-chain record. Returns
|
|
238
|
+
/** Installs a master-chain record. Returns an error message when the module refuses it. */
|
|
252
239
|
#configure(config) {
|
|
253
240
|
const exports = this.#exports;
|
|
254
241
|
if (exports === undefined || this.#handle === 0)
|
|
@@ -265,10 +252,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
265
252
|
? undefined
|
|
266
253
|
: `master configuration was rejected (${result})`;
|
|
267
254
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Posts `alpha2-latency` when the master chain's delay changed: the host's clock subtracts it, as
|
|
270
|
-
* the sound comes out that much after the samples the processor took.
|
|
271
|
-
*/
|
|
255
|
+
/** Posts `alpha2-latency` when the delay changed; the host's clock subtracts it. */
|
|
272
256
|
#reportLatency() {
|
|
273
257
|
const exports = this.#exports;
|
|
274
258
|
if (exports === undefined || this.#handle === 0)
|
|
@@ -289,7 +273,6 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
289
273
|
this.#handle !== 0 &&
|
|
290
274
|
exports.alpha2_worklet_transparent(this.#handle) === 1;
|
|
291
275
|
}
|
|
292
|
-
/** The cached channel views, remade when memory grew or `frames` changed. */
|
|
293
276
|
#viewsFor(exports, frames) {
|
|
294
277
|
const buffer = exports.memory.buffer;
|
|
295
278
|
for (const views of this.#views) {
|
|
@@ -304,7 +287,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
304
287
|
input: indices.map((index) => channel(this.#inputPointer, index)),
|
|
305
288
|
output: indices.map((index) => channel(this.#outputPointer, index)),
|
|
306
289
|
};
|
|
307
|
-
//
|
|
290
|
+
// Drop views over a detached buffer, then the older length.
|
|
308
291
|
this.#views = this.#views.filter((kept) => kept.buffer === buffer);
|
|
309
292
|
if (this.#views.length >= 2)
|
|
310
293
|
this.#views.shift();
|
|
@@ -312,14 +295,11 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
312
295
|
return views;
|
|
313
296
|
}
|
|
314
297
|
/**
|
|
315
|
-
* Reads `frames` samples into
|
|
316
|
-
*
|
|
317
|
-
* on either path.
|
|
298
|
+
* Reads `frames` samples into each target, from the ring or from WebAudio's input at `offset`.
|
|
299
|
+
* Non-finite samples become silence.
|
|
318
300
|
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* WebAudio for exactly the module's channels, so its input needs this only when a host changed
|
|
322
|
-
* the node's channel mode.
|
|
301
|
+
* Channels fold as WebAudio's speaker rules do: extra targets take channel 0, and a single target
|
|
302
|
+
* fed two channels takes their average.
|
|
323
303
|
*/
|
|
324
304
|
#readInput(inputs, targets, frames, offset) {
|
|
325
305
|
if (this.#ring === undefined) {
|
|
@@ -347,8 +327,19 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
347
327
|
}
|
|
348
328
|
this.#readRing(this.#ring, targets, frames);
|
|
349
329
|
}
|
|
350
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* Reads the next `frames` ring samples, reporting underruns. The first read also reports
|
|
332
|
+
* `currentFrame`, which the host uses to align ring samples with output timestamps.
|
|
333
|
+
*/
|
|
351
334
|
#readRing(ring, targets, frames) {
|
|
335
|
+
if (!this.#firstReadReported) {
|
|
336
|
+
this.#firstReadReported = true;
|
|
337
|
+
const frame = globalThis.currentFrame;
|
|
338
|
+
this.port.postMessage({
|
|
339
|
+
type: "alpha2-first-read",
|
|
340
|
+
frame: typeof frame === "number" ? frame : null,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
352
343
|
const produced = ring.read(targets, frames);
|
|
353
344
|
if (produced < frames) {
|
|
354
345
|
this.#underruns += 1;
|
|
@@ -360,7 +351,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
360
351
|
this.#underruns = 0;
|
|
361
352
|
}
|
|
362
353
|
}
|
|
363
|
-
/**
|
|
354
|
+
/** Source plane views, remade when memory grew. */
|
|
364
355
|
#sourcePlanes(exports) {
|
|
365
356
|
const buffer = exports.memory.buffer;
|
|
366
357
|
if (this.#sourceViews?.buffer !== buffer) {
|
|
@@ -373,10 +364,8 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
373
364
|
return this.#sourceViews.planes;
|
|
374
365
|
}
|
|
375
366
|
/**
|
|
376
|
-
* Plays the next `frames` of
|
|
377
|
-
*
|
|
378
|
-
* planes, and runs the master over them (or they are copied out as they are, for a transparent
|
|
379
|
-
* master). Returns false once the module failed, after reporting why.
|
|
367
|
+
* Plays the next `frames` of a project-rate ring, resampled to the context's rate and run
|
|
368
|
+
* through the master chain. Returns false after reporting a module failure.
|
|
380
369
|
*/
|
|
381
370
|
#processConverted(exports, ring, output, frames) {
|
|
382
371
|
for (let start = 0; start < frames; start += this.#maxFrames) {
|
|
@@ -422,8 +411,7 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
422
411
|
return true;
|
|
423
412
|
const frames = output[0]?.length ?? 0;
|
|
424
413
|
if (output.length !== this.#channels) {
|
|
425
|
-
//
|
|
426
|
-
// error.
|
|
414
|
+
// A mismatch means the host created the node with the wrong `outputChannelCount`.
|
|
427
415
|
if (!this.#shapeReported) {
|
|
428
416
|
this.#shapeReported = true;
|
|
429
417
|
this.port.postMessage({
|
|
@@ -442,7 +430,6 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
442
430
|
this.#readInput(inputs, output, frames, 0);
|
|
443
431
|
return true;
|
|
444
432
|
}
|
|
445
|
-
// The context chooses the quantum; the module takes at most its prepared size per call.
|
|
446
433
|
for (let start = 0; start < frames; start += this.#maxFrames) {
|
|
447
434
|
const length = Math.min(this.#maxFrames, frames - start);
|
|
448
435
|
this.#readInput(inputs, this.#viewsFor(exports, length).input, length, start);
|
|
@@ -459,14 +446,14 @@ class Alpha2Processor extends AudioWorkletProcessor {
|
|
|
459
446
|
return false;
|
|
460
447
|
}
|
|
461
448
|
if (status !== 0) {
|
|
462
|
-
// Returning false retires
|
|
449
|
+
// Returning false retires the node; this message is the host's only signal.
|
|
463
450
|
this.port.postMessage({
|
|
464
451
|
type: "alpha2-error",
|
|
465
452
|
message: `AudioWorklet processing failed (${status}); the node has stopped`,
|
|
466
453
|
});
|
|
467
454
|
return false;
|
|
468
455
|
}
|
|
469
|
-
// Recheck
|
|
456
|
+
// Recheck: processing may have grown memory and detached the views.
|
|
470
457
|
const produced = this.#viewsFor(exports, length).output;
|
|
471
458
|
for (let channel = 0; channel < this.#channels; channel += 1) {
|
|
472
459
|
const view = produced[channel];
|
package/dist/audio-worklet.d.ts
CHANGED
|
@@ -2,10 +2,7 @@ import type { AudioRingTransfer } from "./audio-timeline.js";
|
|
|
2
2
|
import type { MasterAudio } from "./project.js";
|
|
3
3
|
/** Options for {@link Alpha2AudioWorkletHost.create}. */
|
|
4
4
|
export interface AudioWorkletHostOptions {
|
|
5
|
-
/**
|
|
6
|
-
* URL of the worklet processor module added to `audioWorklet`. Defaults to
|
|
7
|
-
* {@link alpha2AudioWorkletProcessorUrl}.
|
|
8
|
-
*/
|
|
5
|
+
/** Processor module URL. Defaults to {@link alpha2AudioWorkletProcessorUrl}. */
|
|
9
6
|
readonly processorUrl?: string | URL;
|
|
10
7
|
/** Name the processor module passes to `registerProcessor` (default `alpha2-processor`). */
|
|
11
8
|
readonly processorName?: string;
|
|
@@ -13,40 +10,31 @@ export interface AudioWorkletHostOptions {
|
|
|
13
10
|
readonly numberOfInputs?: number;
|
|
14
11
|
/** Default 1. */
|
|
15
12
|
readonly numberOfOutputs?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Channels of each output. Defaults to two for every output, which is also what the DSP module
|
|
18
|
-
* mixes; the module's channel count is the first entry. Leaving it to WebAudio would size the
|
|
19
|
-
* output from whatever is connected.
|
|
20
|
-
*/
|
|
13
|
+
/** Channels per output (default 2 each). The first entry sets the DSP module's channel count. */
|
|
21
14
|
readonly outputChannelCount?: readonly number[];
|
|
22
15
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* `resampled` through `onDiagnostic`. A node's WebAudio input is at the context's rate already
|
|
28
|
-
* and is never converted. A positive integer; any other value is refused with a `RangeError`.
|
|
16
|
+
* Sample rate of ring audio ({@link useAudioRing}), normally the project's. Defaults to the
|
|
17
|
+
* context's. When it differs from the context's, ring audio is resampled with the engine's
|
|
18
|
+
* band-limited converter and `resampled` is reported through `onDiagnostic`. WebAudio input is
|
|
19
|
+
* never resampled. Must be a positive integer.
|
|
29
20
|
*/
|
|
30
21
|
readonly projectSampleRate?: number;
|
|
31
22
|
/**
|
|
32
|
-
* Called once
|
|
33
|
-
*
|
|
34
|
-
* bit-identical to what an export renders. Defaults to `console.warn`.
|
|
23
|
+
* Called once at startup when playback will differ from an export (currently only `resampled`).
|
|
24
|
+
* Defaults to `console.warn`.
|
|
35
25
|
*/
|
|
36
26
|
readonly onDiagnostic?: (diagnostic: AudioWorkletDiagnostic) => void;
|
|
37
|
-
/** Aborts creation; `create`
|
|
27
|
+
/** Aborts creation; `create` rejects with the signal's reason and disposes the node. */
|
|
38
28
|
readonly signal?: AbortSignal;
|
|
39
29
|
/**
|
|
40
|
-
* Called for every error the running node reports
|
|
41
|
-
*
|
|
42
|
-
* `console.error`, so none of them is silent.
|
|
30
|
+
* Called for every error the running node reports, such as a processor exception, a DSP trap or
|
|
31
|
+
* an unfillable output. Defaults to `console.error`.
|
|
43
32
|
*/
|
|
44
33
|
readonly onError?: (error: Error) => void;
|
|
45
34
|
}
|
|
46
35
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* audio to the context's rate.
|
|
36
|
+
* See {@link AudioWorkletHostOptions.onDiagnostic}. `resampled` means the context rate differs
|
|
37
|
+
* from the project rate.
|
|
50
38
|
*/
|
|
51
39
|
export interface AudioWorkletDiagnostic {
|
|
52
40
|
readonly kind: "resampled";
|
|
@@ -54,8 +42,7 @@ export interface AudioWorkletDiagnostic {
|
|
|
54
42
|
readonly contextSampleRate: number;
|
|
55
43
|
}
|
|
56
44
|
/**
|
|
57
|
-
*
|
|
58
|
-
* `AudioPlaybackClock` subtracts it (its `processing` argument).
|
|
45
|
+
* Node output delay in context-rate samples, for `AudioPlaybackClock`'s `processing` option.
|
|
59
46
|
*/
|
|
60
47
|
export interface AudioProcessingDelay {
|
|
61
48
|
readonly latencySamples: number;
|
|
@@ -64,87 +51,69 @@ export interface AudioProcessingDelay {
|
|
|
64
51
|
export declare const alpha2AudioWorkletProcessorUrl: URL;
|
|
65
52
|
/** URL of the C-ABI DSP wasm module distributed with the alpha2 package. */
|
|
66
53
|
export declare const alpha2AudioWorkletWasmUrl: URL;
|
|
67
|
-
/** Fetches the packaged DSP bytes
|
|
54
|
+
/** Fetches the packaged DSP wasm bytes. */
|
|
68
55
|
export declare function loadAlpha2AudioWorkletWasm(url?: string | URL): Promise<ArrayBuffer>;
|
|
69
56
|
/** Browser host for the C-ABI DSP wasm module; no wasm-bindgen glue is used. */
|
|
70
57
|
export declare class Alpha2AudioWorkletHost {
|
|
71
58
|
/**
|
|
72
|
-
* Adds the processor module
|
|
73
|
-
*
|
|
74
|
-
* ready; later errors go to `options.onError`.
|
|
59
|
+
* Adds the processor module, creates the node and starts the DSP module from a copy of `wasm`.
|
|
60
|
+
* Resolves once the processor is ready; later errors go to `options.onError`.
|
|
75
61
|
*
|
|
76
|
-
* Rejects when the module cannot be added, the processor fails
|
|
77
|
-
* starting, it is not ready within 5 seconds, or `options.signal` aborts.
|
|
78
|
-
* start is disposed.
|
|
62
|
+
* Rejects (and disposes the node) when the module cannot be added, the processor fails while
|
|
63
|
+
* starting, it is not ready within 5 seconds, or `options.signal` aborts.
|
|
79
64
|
*
|
|
80
65
|
* @throws RangeError When `options.projectSampleRate` is not a positive integer.
|
|
81
66
|
*/
|
|
82
67
|
static create(context: BaseAudioContext, wasm: BufferSource, options: AudioWorkletHostOptions): Promise<AudioWorkletNode>;
|
|
83
68
|
/**
|
|
84
|
-
* The node's
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* reads past the one it plays (16 to 18 at the usual rates), so its output is that much behind
|
|
88
|
-
* what it takes from the ring or its input. Zero without either (an engine-mixed node at the
|
|
89
|
-
* project's rate), and for a node `create` did not make.
|
|
69
|
+
* The node's live output delay in context-rate samples: master compressor lookahead plus, when
|
|
70
|
+
* resampling ring audio, the converter's lookahead (16 to 18 samples at common rates). Zero for an
|
|
71
|
+
* engine-mixed node at the project rate and for nodes `create` did not make.
|
|
90
72
|
*
|
|
91
|
-
* The
|
|
92
|
-
*
|
|
93
|
-
* which it reports on its port; pass the object to `AudioPlaybackClock` so the clock says
|
|
94
|
-
* what is being heard.
|
|
73
|
+
* The returned object updates as configurations are applied; pass it to `AudioPlaybackClock` so
|
|
74
|
+
* the clock reports what is being heard.
|
|
95
75
|
*/
|
|
96
76
|
static latency(node: AudioWorkletNode): AudioProcessingDelay;
|
|
97
77
|
}
|
|
98
78
|
/**
|
|
99
|
-
* Points the node at a shared audio ring instead of its WebAudio input.
|
|
100
|
-
*
|
|
101
|
-
* Pass `undefined` to return the node to input processing. Both sides must agree to clear the ring
|
|
102
|
-
* at a seek.
|
|
79
|
+
* Points the node at a shared audio ring instead of its WebAudio input; `undefined` switches back.
|
|
80
|
+
* Both sides must agree to clear the ring at a seek.
|
|
103
81
|
*
|
|
104
|
-
* Resolves once the processor plays from the ring
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* `startRendering()`, whose first quanta may otherwise render without the ring. Rejects when the
|
|
108
|
-
* node is disposed or its processor throws before it answers.
|
|
82
|
+
* Resolves once the processor plays from the ring and {@link Alpha2AudioWorkletHost.latency} is
|
|
83
|
+
* updated. Await it before `OfflineAudioContext.startRendering()`, or the first quanta may render
|
|
84
|
+
* without the ring. Rejects when the node is disposed or its processor throws first.
|
|
109
85
|
*/
|
|
110
86
|
export declare function useAudioRing(node: AudioWorkletNode, ring: AudioRingTransfer | undefined): Promise<void>;
|
|
111
87
|
/**
|
|
112
|
-
* Installs a project master bus in the running worklet
|
|
113
|
-
*
|
|
114
|
-
* tail or empty the compressor's lookahead.
|
|
88
|
+
* Installs a project master bus in the running worklet as an edit. Kept and changed effects keep
|
|
89
|
+
* their state, so adjusting a control does not cut a reverb tail or reset compressor lookahead.
|
|
115
90
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
91
|
+
* Applied as the engine does (effects, gain, limiter), without the engine's loudness normalization
|
|
92
|
+
* gain, which the master bus does not carry.
|
|
118
93
|
*
|
|
119
|
-
* Resolves once the
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* answers.
|
|
94
|
+
* Resolves once the new master runs and {@link Alpha2AudioWorkletHost.latency} reflects it.
|
|
95
|
+
* Rejects with a `RangeError` for a keyframed master gain (nothing is posted), with the processor's
|
|
96
|
+
* reason when it refuses the record (the old chain keeps running), or when the node is disposed or
|
|
97
|
+
* its processor throws first.
|
|
124
98
|
*/
|
|
125
99
|
export declare function configureMasterAudio(node: AudioWorkletNode, master: MasterAudio | undefined): Promise<void>;
|
|
126
100
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* `renderAudio` has already applied the project master gain, effects, and limiter. Ring-buffer
|
|
130
|
-
* preview must therefore bypass the worklet master chain or preview would process it twice while
|
|
131
|
-
* offline export processes it once.
|
|
101
|
+
* Makes the worklet a transparent transport for engine-mixed audio, since `renderAudio` has already
|
|
102
|
+
* applied the master chain.
|
|
132
103
|
*
|
|
133
104
|
* Resolves once the processor is transparent; rejects as {@link configureMasterAudio} does.
|
|
134
105
|
*/
|
|
135
106
|
export declare function configureEngineMixedAudio(node: AudioWorkletNode): Promise<void>;
|
|
136
107
|
/**
|
|
137
|
-
* Clears the worklet's DSP
|
|
138
|
-
*
|
|
108
|
+
* Clears the worklet's DSP state and transport position. Rejects when the node is disposed or its
|
|
109
|
+
* processor throws first.
|
|
139
110
|
*/
|
|
140
111
|
export declare function resetAudioWorklet(node: AudioWorkletNode): Promise<void>;
|
|
141
112
|
/**
|
|
142
|
-
*
|
|
113
|
+
* Permanently stops and disconnects the node.
|
|
143
114
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* while the context lives on. A configuration the processor has not answered yet, and any made
|
|
148
|
-
* afterwards, rejects.
|
|
115
|
+
* Disconnecting alone leaves the processor running and holding DSP memory until the context
|
|
116
|
+
* closes, so call this for every node no longer used. Pending and later configuration requests
|
|
117
|
+
* reject.
|
|
149
118
|
*/
|
|
150
119
|
export declare function disposeAudioWorklet(node: AudioWorkletNode): void;
|