/** * Write the three v1 instrument files. The builder (author/build.ts) is the * source of truth; the JSON in instruments/ is its checked-in output, so * `npm run author` after an edit regenerates them deterministically. */ import { mkdirSync, writeFileSync } from 'node:fs'; import { buildInstrument } from '../author/build.ts'; const instruments = [ buildInstrument({ name: 'drum', description: 'A struck membrane over a cylindrical shell. The head’s inharmonic modes plus the cavity under it are what make it a drum.', object: 'membrane', body: 'shell', }), buildInstrument({ name: 'dulcimer', description: 'One plucked string over a rigid box with a sound hole, radiating along its line and driving a bridge patch above the plate.', object: 'string', body: 'box', defaults: { mic_x: 0.12, mic_y: 0.08, mic_z: 0.1 }, }), buildInstrument({ name: 'chime', description: 'A stiff bar in open air, struck. No tension, so the stiffness sets the partials at n²·f1, which is the bell-like sound.', object: 'bar', body: 'none', defaults: { mic_x: 0.12, mic_y: 0.08, mic_z: 0.1 }, }), ]; mkdirSync(new URL('../instruments', import.meta.url), { recursive: true }); for (const inst of instruments) { const path = new URL(`../instruments/${inst.name}.instrument.json`, import.meta.url); writeFileSync(path, `${JSON.stringify(inst, null, 2)}\n`); console.log(`wrote instruments/${inst.name}.instrument.json (${inst.params.length} params, ${Object.keys(inst.shaders).length} shaders)`); }