@onda-lang/webaudio 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,7 +49,9 @@ After construction, the normal f32 render callback reuses cached Wasm-memory vie
49
49
  host-side allocation or memory growth. Full-block f32 inputs and outputs use typed-array bulk copies;
50
50
  segmented callbacks and other ABI scalar widths use preallocated typed views with conversion loops
51
51
  (i64 input conversion necessarily creates JavaScript `BigInt` values). External buffers are copied
52
- into Wasm with typed-array bulk operations during construction.
52
+ into Wasm with typed-array bulk operations during construction. Every declared external buffer must
53
+ be supplied with nonempty data; the adapter rejects missing or empty bindings before creating the
54
+ rendering node.
53
55
 
54
56
  Artifact descriptors and module exports are validated by the shared, compiler-free
55
57
  `@onda-lang/processor-abi` package before anything reaches the rendering thread.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onda-lang/webaudio",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Optional Web Audio adapter for Onda processor WebAssembly artifacts",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/onda-lang/onda.git",
10
10
  "directory": "packages/onda_webaudio"
11
11
  },
12
- "homepage": "https://onda-lang.github.io/onda/",
12
+ "homepage": "https://onda-lang.org/",
13
13
  "bugs": {
14
14
  "url": "https://github.com/onda-lang/onda/issues"
15
15
  },
@@ -32,7 +32,7 @@
32
32
  "test": "node --test"
33
33
  },
34
34
  "dependencies": {
35
- "@onda-lang/processor-abi": "0.5.0"
35
+ "@onda-lang/processor-abi": "0.5.1"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
package/src/worklet.js CHANGED
@@ -609,46 +609,34 @@ class OndaWasmProcessor extends AudioWorkletProcessor {
609
609
  if (!Number.isFinite(sampleRate) || sampleRate <= 0) {
610
610
  throw new Error(`Onda buffer '${buffer.name}' has an invalid sample rate`);
611
611
  }
612
- let frames;
613
- let channels;
614
- let pointer;
615
612
  if (length === 0) {
616
- if (
617
- (descriptor.frames !== undefined && descriptor.frames !== 0)
618
- || (descriptor.channels !== undefined && descriptor.channels !== 0)
619
- ) {
620
- throw new Error(
621
- `Onda buffer '${buffer.name}' empty data requires zero frames and channels`,
622
- );
623
- }
624
- frames = 0;
625
- channels = 0;
626
- pointer = 0;
627
- } else {
628
- const declaredChannels = Number(buffer.static_channels ?? 0);
629
- channels = Number(descriptor.channels ?? declaredChannels);
630
- if (!Number.isInteger(channels) || channels <= 0) {
631
- throw new Error(`Onda buffer '${buffer.name}' requires channels > 0`);
632
- }
633
- if (declaredChannels && channels !== declaredChannels) {
634
- throw new Error(
635
- `Onda buffer '${buffer.name}' requires ${declaredChannels} channel(s)`,
636
- );
637
- }
638
- frames = Number(descriptor.frames ?? length / channels);
639
- if (
640
- !Number.isInteger(frames)
641
- || frames <= 0
642
- || frames * channels !== length
643
- ) {
644
- throw new Error(
645
- `Onda buffer '${buffer.name}' data does not match its frame/channel shape`,
646
- );
647
- }
648
- const elementSize = this.scalarByteSize(buffer.scalar);
649
- pointer = this.alloc(length * elementSize, elementSize);
650
- this.writeScalarValues(pointer, buffer.scalar, data, length);
613
+ throw new Error(
614
+ `Onda buffer '${buffer.name}' requires non-empty bound data`,
615
+ );
616
+ }
617
+ const declaredChannels = Number(buffer.static_channels ?? 0);
618
+ const channels = Number(descriptor.channels ?? declaredChannels);
619
+ if (!Number.isInteger(channels) || channels <= 0) {
620
+ throw new Error(`Onda buffer '${buffer.name}' requires channels > 0`);
621
+ }
622
+ if (declaredChannels && channels !== declaredChannels) {
623
+ throw new Error(
624
+ `Onda buffer '${buffer.name}' requires ${declaredChannels} channel(s)`,
625
+ );
626
+ }
627
+ const frames = Number(descriptor.frames ?? length / channels);
628
+ if (
629
+ !Number.isInteger(frames)
630
+ || frames <= 0
631
+ || frames * channels !== length
632
+ ) {
633
+ throw new Error(
634
+ `Onda buffer '${buffer.name}' data does not match its frame/channel shape`,
635
+ );
651
636
  }
637
+ const elementSize = this.scalarByteSize(buffer.scalar);
638
+ const pointer = this.alloc(length * elementSize, elementSize);
639
+ this.writeScalarValues(pointer, buffer.scalar, data, length);
652
640
  const view = this.memoryView();
653
641
  view.setUint32(this.bufferPointersPtr + bufferId * 4, pointer, true);
654
642
  view.setInt32(this.bufferFramesPtr + bufferId * 4, frames, true);