@onda-lang/webaudio 0.8.37 → 0.8.39
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 +3 -3
- package/api.md +9 -2
- package/package.json +2 -2
- package/src/execution-output-ring.js +6 -1
- package/src/index.js +9 -0
package/README.md
CHANGED
|
@@ -182,7 +182,7 @@ and can be set to zero to suppress host delivery without suppressing argument ev
|
|
|
182
182
|
collection is inactive while no listener is registered, avoiding record packing and transport work
|
|
183
183
|
in the render callback. Listeners added later with `processor.onPrint(...)` receive subsequent
|
|
184
184
|
executions; use the construction option above when initialized-code output must be observed.
|
|
185
|
-
See the
|
|
185
|
+
See the [host output guide](../../docs/host-output.md#prints) for scalar formatting,
|
|
186
186
|
source metadata, and the equivalent Rust, C, and raw processor APIs.
|
|
187
187
|
|
|
188
188
|
## Delegates
|
|
@@ -216,8 +216,8 @@ not a compiler-computable exact whole-call size: occurrence counts and slice pay
|
|
|
216
216
|
runtime-dependent. The worklet supplies delegate storage to generated code only while at least one
|
|
217
217
|
listener is registered, and decoding happens on the main side. `overflowCount` reports insufficient
|
|
218
218
|
configured capacity; `transportDropCount` separately reports records discarded by the bounded
|
|
219
|
-
worklet-to-main queue. Internal Onda `when` handlers still run in either case. See the
|
|
220
|
-
[
|
|
219
|
+
worklet-to-main queue. Internal Onda `when` handlers still run in either case. See the
|
|
220
|
+
[host output guide](../../docs/host-output.md#delegates) for sizing and lifecycle details.
|
|
221
221
|
|
|
222
222
|
When print and delegate listeners are both active, the adapter invokes them in authored order for
|
|
223
223
|
each init, event, or process segment. It may split one stream's batch around an occurrence from the
|
package/api.md
CHANGED
|
@@ -70,7 +70,7 @@ The returned instance provides:
|
|
|
70
70
|
- `compileSource(source, options?)` and `inspectSourceConstants(source, options?)`.
|
|
71
71
|
- `compileWorkspace(workspace, options?)` and `inspectWorkspaceConstants(workspace, options?)`.
|
|
72
72
|
- `compileProjectImage(bytes, options?)` and `inspectProjectImageConstants(bytes, options?)`.
|
|
73
|
-
- `createProjectImage(sourceGraph, buffers?)`, `inspectProjectImage(bytes)`,
|
|
73
|
+
- `createProjectImage(sourceGraph, buffers?, constants?)`, `inspectProjectImage(bytes)`,
|
|
74
74
|
`loadProjectFiles(files, projectFilePath?)`, and `materializeProjectImage(bytes, names?)`.
|
|
75
75
|
- `encodeBufferAsset(binding)`, `decodeBufferAsset(bytes)`, and `decodeBufferFile(bytes, path?)`.
|
|
76
76
|
- `projectCapabilities()` for supported image, buffer, and standard-library versions.
|
|
@@ -78,6 +78,9 @@ The returned instance provides:
|
|
|
78
78
|
- `dispose()`, an idempotent terminal release of compiler and worker resources.
|
|
79
79
|
|
|
80
80
|
Compile options accept `sampleRate`, `blockSize`, typed compile-constant overrides, and `codegen`.
|
|
81
|
+
Workspaces may carry `constants` in project-manifest form (numbers, booleans, decimal strings for
|
|
82
|
+
`i64`, and primitive arrays). These are project defaults; explicit `options.constants` take
|
|
83
|
+
precedence. Pass the same defaults to `createProjectImage` when exporting an edited workspace.
|
|
81
84
|
The sample rate defaults to 48000 Hz and the block size to 512 frames.
|
|
82
85
|
Code generation can select optimization level `0..4`, shrink level `0..2`, strict or fast math,
|
|
83
86
|
SIMD, loop-containing inlining, and optional WAT emission. A successful compilation returns an
|
|
@@ -136,6 +139,9 @@ endpoints, apply linear, logarithmic, or curved scale, and clamp and snap to the
|
|
|
136
139
|
|
|
137
140
|
### Delegates and print output
|
|
138
141
|
|
|
142
|
+
See the [host output guide](https://onda-lang.org/docs/host-output/#javascript-and-web-audio)
|
|
143
|
+
for batch sizing, decoding, formatting, and Web Audio listener examples.
|
|
144
|
+
|
|
139
145
|
Complete wasm32 processor exports receive an optional execution-output descriptor containing
|
|
140
146
|
independently nullable delegate and print batches. Allocate all descriptors and storage before
|
|
141
147
|
real-time execution. Their linear-memory regions must be mutually disjoint and must not overlap any
|
|
@@ -156,7 +162,7 @@ chronological output stream.
|
|
|
156
162
|
|
|
157
163
|
Batch capacity is host policy. `overflowCount` reports whole records that did not fit; it is not a
|
|
158
164
|
byte count. Consume the returned storage before reusing it for another init, process, or event call.
|
|
159
|
-
See the [language guide](https://onda-lang.org/docs/language/#delegates) for authored semantics and
|
|
165
|
+
See the [language guide](https://onda-lang.org/docs/language/#delegates-and-when) for authored semantics and
|
|
160
166
|
the [processor API](https://onda-lang.org/docs/processor-api/#call-scoped-execution-output) for
|
|
161
167
|
physical record layout.
|
|
162
168
|
|
|
@@ -425,6 +431,7 @@ OndaProcessorInitMode
|
|
|
425
431
|
OndaProcessorMetadata
|
|
426
432
|
OndaProjectBufferInfo
|
|
427
433
|
OndaProjectCapabilities
|
|
434
|
+
OndaProjectConstant
|
|
428
435
|
OndaProjectImageInfo
|
|
429
436
|
OndaProjectMaterialization
|
|
430
437
|
OndaResolvedCompileConstValue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onda-lang/webaudio",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Optional Web Audio adapter for Onda processor WebAssembly artifacts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"prepack": "node ../../scripts/stage-web-api-docs.mjs"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@onda-lang/processor-abi": "0.8.
|
|
37
|
+
"@onda-lang/processor-abi": "0.8.39"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
@@ -63,10 +63,13 @@ export function createExecutionOutputRing(
|
|
|
63
63
|
throw new Error("combined execution-output capacity exceeds the JavaScript size limit");
|
|
64
64
|
}
|
|
65
65
|
const slotBytes = align4(SLOT_HEADER_BYTES + payloadBytes);
|
|
66
|
-
const
|
|
66
|
+
const availableSlots = Math.max(
|
|
67
67
|
1,
|
|
68
68
|
Math.min(MAX_RING_SLOTS, Math.floor(budgetBytes / slotBytes)),
|
|
69
69
|
);
|
|
70
|
+
// A power-of-two capacity divides the u32 counter period, so wrapping the
|
|
71
|
+
// counters cannot alias a slot that still holds an unread record.
|
|
72
|
+
const slotCount = 2 ** Math.floor(Math.log2(availableSlots));
|
|
70
73
|
const totalBytes = CONTROL_BYTES + slotCount * slotBytes;
|
|
71
74
|
let buffer;
|
|
72
75
|
try {
|
|
@@ -105,6 +108,8 @@ export function openExecutionOutputRing(buffer) {
|
|
|
105
108
|
(control[CONTROL_MAGIC] >>> 0) !== RING_MAGIC
|
|
106
109
|
|| (control[CONTROL_VERSION] >>> 0) !== RING_VERSION
|
|
107
110
|
|| slotCount === 0
|
|
111
|
+
|| slotCount > MAX_RING_SLOTS
|
|
112
|
+
|| (slotCount & (slotCount - 1)) !== 0
|
|
108
113
|
|| CONTROL_BYTES + slotCount * slotBytes !== buffer.byteLength
|
|
109
114
|
) {
|
|
110
115
|
throw new Error("execution-output ring has an invalid layout");
|
package/src/index.js
CHANGED
|
@@ -394,6 +394,14 @@ export class OndaAudioProcessor {
|
|
|
394
394
|
if (error) pending.reject(error);
|
|
395
395
|
else pending.resolve(message);
|
|
396
396
|
};
|
|
397
|
+
this.handleProcessorError = (event) => {
|
|
398
|
+
const error = event.error instanceof Error
|
|
399
|
+
? event.error
|
|
400
|
+
: new Error(event.message || "Onda AudioWorklet processor failed");
|
|
401
|
+
this.notifyListeners(this.executionErrorListeners, error);
|
|
402
|
+
this.close(error);
|
|
403
|
+
};
|
|
404
|
+
node.addEventListener("processorerror", this.handleProcessorError);
|
|
397
405
|
node.port.addEventListener("message", this.handleMessage);
|
|
398
406
|
node.port.start?.();
|
|
399
407
|
if (this.printListeners.size !== 0) this.startExecutionOutputDrain();
|
|
@@ -909,6 +917,7 @@ export class OndaAudioProcessor {
|
|
|
909
917
|
}
|
|
910
918
|
}
|
|
911
919
|
this.node.port.removeEventListener("message", this.handleMessage);
|
|
920
|
+
this.node.removeEventListener("processorerror", this.handleProcessorError);
|
|
912
921
|
this.stopExecutionOutputDrain();
|
|
913
922
|
for (const pending of this.pending.values()) pending.reject(this.closeReason);
|
|
914
923
|
this.pending.clear();
|