import type { ParamSpec } from "../../core/params.ts"; import { NOTE_INSTRUMENTS } from "../../instruments/index.ts"; import { schema as c01 } from "../c01-poincare/schema.ts"; // Composition 2 shares most settings with composition 1 (same meanings and ranges). const pick = (key: string, o: Partial = {}): ParamSpec => { const s = c01.find((x) => x.key === key); if (!s) throw new Error(`no setting ${key} in composition 1`); return { ...s, ...o } as ParamSpec; }; export const SLOTS = 6; const SLOT_DEFAULTS: [string, number][] = [ ["modal: Nylon harp", 0], ["modal: Marimba", -1], ["modal: Vibraphone", 0], ["modal: Church bell", -1], ["modal: Steel-string pluck", 0], ["modal: Glass harmonics", 1], ]; export const schema: ParamSpec[] = [ // ── form ── ...["duration", "peakTime", "holdTime", "energyStart"].map((k) => pick(k)), pick("energyPeak", { default: 0.4 }), ...["riseShape", "riseCurve", "fallCurve", "restEnergy", "finalHold", "finalFade"].map((k) => pick(k)), // ── physics ── pick("speed", { default: 40 }), ...["massRatio", "lengthRatio", "tau", "seed"].map((k) => pick(k)), // ── orbits ── { group: "orbits", key: "orbitCount", label: "orbits", kind: "number", default: 15, min: 1, max: 20, step: 1, hint: "pendulums, all following the same energy; each starts at a random place" }, { group: "orbits", key: "colors", label: "colors", kind: "text", default: "#d6b37a, #7fa8cf, #c48bb8, #93bf8a, #d48f7f, #a9a6e0", hint: "comma-separated CSS colors; orbit n uses color n (cycling)", }, ...Array.from({ length: SLOTS }, (_, i): ParamSpec[] => [ { group: "orbits", key: `slot${i + 1}Instrument`, label: `instrument ${i + 1}`, kind: "select", default: SLOT_DEFAULTS[i][0], options: Object.keys(NOTE_INSTRUMENTS), hint: `orbits ${i + 1}, ${i + 1 + SLOTS}, ${i + 1 + 2 * SLOTS}, … play this instrument`, }, { group: "orbits", key: `slot${i + 1}Octave`, label: `octave ${i + 1}`, kind: "number", default: SLOT_DEFAULTS[i][1], min: -3, max: 3, step: 1, hint: "register shift for this instrument" }, ]).flat(), pick("modalCustom", { group: "orbits", hint: "for “modal: custom” in any slot: paste JSON from modal-synth’s Copy button" }), // ── notes (one per crossing, per orbit) ── pick("scale", { default: "dorian" }), ...["root", "pitchSource", "thetaRange", "pitchLow", "pitchHigh", "pitchCurve", "invertPitch", "p2Ref", "loudCurve", "loudFloor", "notesLevel", "noteLength", "panAmount"].map((k) => pick(k)), // ── hum ── ...c01.filter((s) => s.group === "hum"), // ── visual ── pick("fade", { default: 20, hint: "how long each live crossing dot stays visible" }), ...["plotZoom", "zoomSmooth", "plotP"].map((k) => pick(k)), pick("pointSize", { default: 2.5 }), // ── portrait: computed at frozen energy, refreshed (crossfading) as the energy moves ── pick("orbits", { key: "portrait", group: "portrait", label: "show portrait", hint: "grey background: the section's structure at the current energy" }), pick("orbitCount", { key: "portraitCount", group: "portrait" }), pick("orbitCpu", { key: "portraitCpu", group: "portrait" }), pick("orbitLife", { key: "portraitLife", group: "portrait" }), pick("orbitBand", { key: "portraitBand", group: "portrait" }), pick("orbitMinHold", { key: "portraitMinHold", group: "portrait" }), pick("orbitMaxPoints", { key: "portraitMaxPoints", group: "portrait" }), pick("orbitXfade", { key: "portraitXfade", group: "portrait" }), pick("orbitAlpha", { key: "portraitAlpha", group: "portrait", default: 0.15 }), pick("orbitSize", { key: "portraitSize", group: "portrait" }), { group: "portrait", key: "traces", label: "trace orbits", kind: "bool", default: true, hint: "with each portrait, follow every pendulum from its current state (energy frozen) and draw the orbit it's on, in its color" }, { group: "portrait", key: "traceMax", label: "trace length", kind: "number", default: 1500, min: 50, max: 10000, log: true, hint: "crossings computed per orbit trace" }, { group: "portrait", key: "traceAlpha", label: "trace brightness", kind: "number", default: 0.75, min: 0.02, max: 1, step: 0.01 }, { group: "portrait", key: "traceSize", label: "trace point size", kind: "number", default: 1.5, min: 0.5, max: 4, step: 0.1, unit: "px" }, ];