@vessel-dsp/chain 0.1.0 → 0.1.2

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 (2) hide show
  1. package/README.md +49 -40
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -5,6 +5,16 @@ profiling, compiled circuit runtimes, amp shaping, NAM (`.nam`) playback,
5
5
  cabinet IR convolution, and master output. No UI, no audio runtime, no file
6
6
  access.
7
7
 
8
+ ## Install
9
+
10
+ `@vessel-dsp/chain` 0.1.1 is on npm, with its pinned `@vessel-dsp/compiler`
11
+ 0.2.0, `@vessel-dsp/runtime` 0.2.1, and `@vessel-dsp/core` dependencies coming
12
+ along automatically:
13
+
14
+ ```bash
15
+ bun add @vessel-dsp/chain
16
+ ```
17
+
8
18
  ## Nodes
9
19
 
10
20
  - `InputProfileNode` (`input-profile`): pickup type, impedance loading,
@@ -63,22 +73,37 @@ with its glue `nam-engine/nam-engine.js` (MIT; see `nam-engine/NOTICE.md`).
63
73
  whose licences are their authors'. The package ships the engine only; the
64
74
  caller supplies the model's JSON text.
65
75
 
66
- Usage (Bun/Node):
76
+ Usage (Bun/Node — the wasm bytes resolve from the installed package, since a
77
+ worklet scope has no `fetch`):
67
78
 
68
79
  ```ts
69
80
  import { readFileSync } from "node:fs";
81
+ import { fileURLToPath } from "node:url";
70
82
  import { instantiateNamEngine, NamNode, SignalChain } from "@vessel-dsp/chain";
71
83
 
84
+ const model = JSON.stringify({
85
+ version: "0.5.0",
86
+ architecture: "Linear",
87
+ config: {
88
+ receptive_field: 4,
89
+ bias: false,
90
+ in_channels: 1,
91
+ out_channels: 1,
92
+ implementation: "direct",
93
+ },
94
+ weights: [0.5, -0.25, 0.125, 0.0625],
95
+ metadata: { loudness: -14.0 },
96
+ sample_rate: 48000,
97
+ });
98
+
72
99
  const factory = (await import("@vessel-dsp/chain/nam-engine.js")).default;
100
+ const wasmUrl = import.meta.resolve("@vessel-dsp/chain/nam-engine.wasm");
73
101
  const engine = await instantiateNamEngine(
74
- readFileSync(new URL("./nam-engine/nam-engine.wasm", import.meta.url)),
102
+ readFileSync(fileURLToPath(wasmUrl)),
75
103
  factory,
76
104
  );
77
105
  const chain = new SignalChain({ sampleRate: 48000 });
78
- chain.addNode(new NamNode("nam-amp", "NAM Amp", {
79
- engine,
80
- model: readFileSync("my-amp.nam", "utf8"),
81
- }));
106
+ chain.addNode(new NamNode("nam-amp", "NAM Amp", { engine, model }));
82
107
  const out = chain.process(new Float64Array(128));
83
108
  ```
84
109
 
@@ -170,52 +195,36 @@ one resolved external rail applies to the resolved one and keeps the
170
195
  refusals visible. Missing source text or zero resolved supplies throws with
171
196
  the refusal reason codes and rail ids.
172
197
 
173
- Example with `big-muff-pi.vdsp` from the corpus, compiled with
174
- `pedalPartCatalog` (read-only, not a committed test):
198
+ Example: the resistor-divider fixture has no power section, so applying a
199
+ profile without source text throws naming the missing join input (the Signal
200
+ Chain guide works a resolving battery-powered stage end to end):
175
201
 
176
202
  ```ts
177
- import { readFileSync } from "node:fs";
178
- import { compile, pedalPartCatalog } from "@vessel-dsp/compiler";
203
+ import { compile, emptyRegistry } from "@vessel-dsp/compiler";
204
+ import { resistorDivider } from "@vessel-dsp/compiler/fixtures";
179
205
  import { RuntimeNode, SUPPLY_PROFILES } from "@vessel-dsp/chain";
180
206
 
181
- const source = readFileSync("big-muff-pi.vdsp", "utf8");
182
- const program = (() => {
183
- const result = compile(source, { registry: pedalPartCatalog });
184
- if (result.status !== "ok") throw new Error("compile failed");
185
- return result.program;
186
- })();
187
-
188
- function rms(values: Float64Array): number {
189
- let sum = 0;
190
- for (const v of values) sum += v * v;
191
- return Math.sqrt(sum / values.length);
192
- }
193
-
194
- const input = new Float64Array(4800);
195
- for (let i = 0; i < input.length; i++) {
196
- input[i] = 0.3 * Math.sin((2 * Math.PI * 440 * i) / 48000);
197
- }
198
-
199
- for (const id of ["ideal", "alkaline-depleted-specimen"] as const) {
200
- const profile = SUPPLY_PROFILES.find((p) => p.id === id)!;
201
- const node = new RuntimeNode("muff", "Big Muff", program, { source });
202
- node.prepare(48000);
203
- node.setSupplyProfile(profile);
204
- node.process(input);
205
- console.log(`${id} rms: ${rms(node.process(input)).toFixed(5)}`);
207
+ const compiled = compile(resistorDivider, { registry: emptyRegistry });
208
+ if (compiled.status !== "ok") throw new Error("compile failed");
209
+ const node = new RuntimeNode("div", "Divider", compiled.program);
210
+ node.prepare(48000);
211
+ try {
212
+ node.setSupplyProfile(SUPPLY_PROFILES[1]);
213
+ } catch (e) {
214
+ console.log("refused:", (e as Error).message);
206
215
  }
207
216
  ```
208
217
 
209
218
  ```text
210
- ideal rms: 0.20087
211
- alkaline-depleted-specimen rms: 0.19471
219
+ refused: setSupplyProfile: no source text was given to this RuntimeNode, so no external supply can be resolved: pass the .vdsp text as the fourth constructor argument
212
220
  ```
213
221
 
214
222
  Limits, stated plainly:
215
223
 
216
- - It uses the TypeScript reference runtime. The WebAssembly console the
217
- workbench product runs needs the same setter in the workbench repo and is
218
- not done.
224
+ - It uses the TypeScript reference console. The WASM console in
225
+ `@vessel-dsp/runtime` 0.2.1 exposes the same `getSupplies`/`setSupply`
226
+ pair for hosts that drive it directly; `RuntimeNode` drives the reference
227
+ console.
219
228
  - Op-amp stages draw almost no supply current in the model, so sag on
220
229
  op-amp-heavy pedals is under-reported.
221
230
  - The model source can absorb current a real cell cannot, so a hard clipper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vessel-dsp/chain",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Headless audio signal chain graph engine for VesselDSP circuits, guitar profiling, amp shaping, and cabinet IRs.",
5
5
  "keywords": [
6
6
  "dsp",
@@ -59,7 +59,7 @@
59
59
  "dependencies": {
60
60
  "@vessel-dsp/compiler": "0.2.0",
61
61
  "@vessel-dsp/core": "0.16.0",
62
- "@vessel-dsp/runtime": "0.2.0"
62
+ "@vessel-dsp/runtime": "0.2.2"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public"