import type { ParamSpec } from "../../core/params.ts"; import { NOTE_INSTRUMENTS } from "../../instruments/index.ts"; import { schema as c01 } from "../c01-poincare/schema.ts"; 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 schema: ParamSpec[] = [ // ── form ── { group: "form", key: "freeTime", label: "swinging", kind: "number", default: 40, min: 5, max: 600, step: 1, unit: "s", hint: "free (undamped) swinging before the damping begins" }, { group: "form", key: "dampTime", label: "damping", kind: "number", default: 20, min: 2, max: 300, step: 0.5, unit: "s", hint: "time for the damping to bring every pendulum to rest" }, { group: "form", key: "dampCurve", label: "damping curve", kind: "number", default: 1.5, min: 0.3, max: 5, log: true, hint: "energy follows (1 − u)^curve during the damping; >1 settles fast then lingers" }, { group: "form", key: "tau", label: "damping follow", kind: "number", default: 2, min: 0.1, max: 50, log: true, unit: "sim s", hint: "how closely each pendulum's energy follows the damping curve" }, pick("restEnergy", { hint: "after the damping, a pendulum counts as at rest below this energy: its last note rings out" }), pick("finalHold"), pick("finalFade"), // ── pendulums ── { group: "pendulums", key: "count", label: "pendulums", kind: "number", default: 12, min: 1, max: 24, step: 1 }, { group: "pendulums", key: "releaseAngle", label: "release angle", kind: "number", default: 120, min: 10, max: 179, step: 1, unit: "°", hint: "both arms released from rest at this angle from straight down" }, { group: "pendulums", key: "jitter", label: "angle variation", kind: "number", default: 3, min: 0, max: 30, step: 0.1, unit: "°", hint: "each play varies the release angles by up to this much (seed fixes it)" }, { group: "pendulums", key: "separateAt", label: "separate after", kind: "number", default: 8, min: 1, max: 60, step: 0.5, unit: "s", hint: "the tiny offsets between pendulums are calibrated so the outermost visibly separate at about this time" }, { group: "pendulums", key: "sepThreshold", label: "“visibly”", kind: "number", default: 0.02, min: 0.001, max: 0.5, log: true, hint: "bob separation (fraction of the pendulum's length) that counts as separated" }, { group: "pendulums", key: "speed", label: "speed", kind: "number", default: 2.5, min: 0.25, max: 20, log: true, unit: "×", hint: "simulated seconds per real second" }, pick("massRatio", { group: "pendulums" }), pick("lengthRatio", { group: "pendulums" }), pick("seed", { group: "pendulums", hint: "0 = a different release every play" }), // ── notes: one per crossing of the vertical by a bottom bob ── { group: "notes", key: "instrument", label: "instrument", kind: "select", default: "modal: Vibraphone", options: Object.keys(NOTE_INSTRUMENTS) }, pick("modalCustom"), { group: "notes", key: "pitchMode", label: "pitch", kind: "select", default: "chord", options: ["chord", "motion"], hint: "chord: each pendulum has its own note of a chord spread over the range. motion: pitch from the bob's speed at the crossing" }, { group: "notes", key: "directionChords", label: "two chords", kind: "bool", default: true, hint: "chord mode: left-to-right and right-to-left crossings play two interleaved chords, so the swings alternate between them" }, pick("scale", { default: "dorian" }), pick("root"), pick("pitchLow", { default: 50 }), pick("pitchHigh", { default: 86 }), { group: "notes", key: "loudRef", label: "speed for full", kind: "number", default: 0.6, min: 0.05, max: 1, step: 0.01, hint: "bob speed (fraction of the fastest possible at release energy) that gives full loudness (and top pitch in motion mode)" }, pick("loudCurve"), pick("loudFloor"), pick("notesLevel", { default: -8 }), pick("noteLength", { default: 2 }), { group: "notes", key: "directionPan", label: "pan with direction", kind: "number", default: 0.35, min: 0, max: 1, step: 0.01, hint: "a crossing is panned toward the side the bob is heading" }, { group: "notes", key: "reverbTime", label: "reverb time", kind: "number", default: 3.5, min: 0.3, max: 12, log: true, unit: "s", hint: "applies on the next play" }, { group: "notes", key: "streamAudio", label: "render ahead", kind: "bool", default: true, hint: "render the instrument in a background thread, ~2 s ahead (applies on the next play)" }, // ── visual ── { group: "visual", key: "trails", label: "trails", kind: "bool", default: true }, { group: "visual", key: "trailLength", label: "trail length", kind: "number", default: 3, min: 0.2, max: 20, log: true, unit: "s" }, { group: "visual", key: "trailWidth", label: "trail width", kind: "number", default: 1.2, min: 0.3, max: 5, step: 0.1, unit: "px" }, { group: "visual", key: "armAlpha", label: "arm opacity", kind: "number", default: 0.75, min: 0.05, max: 1, step: 0.01 }, { group: "visual", key: "bobSize", label: "bob size", kind: "number", default: 3, min: 0.5, max: 10, step: 0.1, unit: "px" }, { group: "visual", key: "saturation", label: "color saturation", kind: "number", default: 35, min: 0, max: 100, step: 1, unit: "%" }, ];