1/**
2 * Write the three v1 instrument files. The builder (author/build.ts) is the
3 * source of truth; the JSON in instruments/ is its checked-in output, so
4 * `npm run author` after an edit regenerates them deterministically.
5 */
6import { mkdirSync, writeFileSync } from 'node:fs';
7import { buildInstrument } from '../author/build.ts';
9const instruments = [
10 buildInstrument({
11 name: 'drum',
12 description:
13 'A struck membrane over a cylindrical shell. The head’s inharmonic modes plus the cavity under it are what make it a drum.',
14 object: 'membrane',
15 body: 'shell',
16 }),
17 buildInstrument({
18 name: 'dulcimer',
19 description:
20 'One plucked string over a rigid box with a sound hole, radiating along its line and driving a bridge patch above the plate.',
21 object: 'string',
22 body: 'box',
23 defaults: { mic_x: 0.12, mic_y: 0.08, mic_z: 0.1 },
24 }),
25 buildInstrument({
26 name: 'chime',
27 description:
28 'A stiff bar in open air, struck. No tension, so the stiffness sets the partials at n²·f1, which is the bell-like sound.',
29 object: 'bar',
30 body: 'none',
31 defaults: { mic_x: 0.12, mic_y: 0.08, mic_z: 0.1 },
32 }),
33];
35mkdirSync(new URL('../instruments', import.meta.url), { recursive: true });
36for (const inst of instruments) {
37 const path = new URL(`../instruments/${inst.name}.instrument.json`, import.meta.url);
38 writeFileSync(path, `${JSON.stringify(inst, null, 2)}\n`);
39 console.log(`wrote instruments/${inst.name}.instrument.json (${inst.params.length} params, ${Object.keys(inst.shaders).length} shaders)`);
40}