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: "fallAfter", label: "tips after", kind: "number", default: 5, min: 1, max: 30, step: 0.5, unit: "s", hint: "the nudge from straight up is calibrated so the pendulum visibly tips at about this time" }, { group: "form", key: "freeTime", label: "swinging", kind: "number", default: 60, min: 5, max: 600, step: 1, unit: "s", hint: "time before the stronger damping begins" }, { group: "form", key: "dampTime", label: "damping", kind: "number", default: 20, min: 2, max: 300, step: 0.5, unit: "s", hint: "time over which the damping grows to its final strength" }, { group: "form", key: "dampBase", label: "slight damping", kind: "number", default: 0.004, min: 0, max: 0.1, step: 0.0005, unit: "/sim s", hint: "friction throughout (energy loses roughly this fraction per simulated second)" }, { group: "form", key: "dampEnd", label: "final damping", kind: "number", default: 0.2, min: 0.01, max: 2, log: true, unit: "/sim s", hint: "friction reached by the end of the damping" }, pick("restEnergy", { hint: "after the damping, the pendulum counts as at rest below this energy: the last bottom note rings out" }), pick("finalHold"), pick("finalFade"), // ── pendulum ── { group: "pendulum", key: "speed", label: "speed", kind: "number", default: 1.5, min: 0.25, max: 20, log: true, unit: "×", hint: "simulated seconds per real second" }, { group: "pendulum", key: "tipThreshold", label: "“visibly”", kind: "number", default: 0.02, min: 0.001, max: 0.5, log: true, hint: "sideways bob movement (fraction of the length) that counts as tipping" }, pick("massRatio", { group: "pendulum" }), pick("lengthRatio", { group: "pendulum" }), pick("seed", { group: "pendulum", hint: "0 = a different nudge (side and shape) every play" }), // ── bottom notes: outer bob crossing the vertical below the pivot ── { group: "bottom", key: "bottomInstrument", label: "instrument", kind: "select", default: "modal: Violin", options: Object.keys(NOTE_INSTRUMENTS) }, pick("modalCustom", { group: "bottom" }), { group: "bottom", key: "bottomPitch", label: "pitch", kind: "number", default: 55, min: 12, max: 108, step: 0.5, unit: "midi" }, { group: "bottom", key: "bottomLength", label: "length", kind: "number", default: 0.4, min: 0.05, max: 5, log: true, unit: "s" }, { group: "bottom", key: "minDepth", label: "minimum depth", kind: "number", default: 0.25, min: 0, max: 0.95, step: 0.01, hint: "crossings count only this far below the pivot (fraction of the length); a folded pendulum sweeping its bob past the pivot clicks instead" }, { group: "bottom", key: "firstVel", label: "first note", kind: "number", default: 1, min: 0.05, max: 1, step: 0.01, hint: "strength of the first bottom note (accent)" }, { group: "bottom", key: "maxVel", label: "strongest", kind: "number", default: 0.6, min: 0.05, max: 1, step: 0.01, hint: "strength of later bottom notes at full speed" }, { group: "bottom", key: "loudRef", label: "speed for full", kind: "number", default: 0.8, min: 0.05, max: 1, step: 0.01, hint: "bob speed (fraction of the fastest possible) that gives the strongest note" }, pick("loudCurve", { group: "bottom" }), pick("loudFloor", { group: "bottom", default: 0.15 }), pick("notesLevel", { group: "bottom", default: 6, max: 18 }), { group: "bottom", key: "maxOverlap", label: "overlapping notes", kind: "number", default: 4, min: 1, max: 16, step: 1, hint: "most bottom notes ringing at once (a new one replaces the oldest)" }, { group: "bottom", key: "deviceLimit", label: "limit to device", kind: "bool", default: true, hint: "measure (once per device) how many ringing bottom notes it can render, and allow no more" }, { group: "bottom", key: "streamAudio", label: "render ahead", kind: "bool", default: true, hint: "render the instruments in background threads, ~1 s ahead (applies on the next play)" }, // ── click: the outer bob sweeping past the pivot (within the minimum depth) ── { group: "click", key: "click", label: "click", kind: "bool", default: true, hint: "a click when the outer bob passes the pivot (closer than the minimum depth)" }, { group: "click", key: "clickInstrument", label: "instrument", kind: "select", default: "modal: Viola", options: Object.keys(NOTE_INSTRUMENTS) }, { group: "click", key: "clickPitch", label: "pitch", kind: "number", default: 72, min: 24, max: 120, step: 0.5, unit: "midi" }, { group: "click", key: "clickLength", label: "length", kind: "number", default: 0.5, min: 0.01, max: 2, log: true, unit: "s" }, { group: "click", key: "clickMaxVel", label: "strongest", kind: "number", default: 0.7, min: 0.05, max: 1, step: 0.01, hint: "strength at full bob speed (follows the speed like the bottom notes)" }, { group: "click", key: "clickLevel", label: "level", kind: "number", default: -4, min: -48, max: 6, step: 0.5, unit: "dB" }, // ── height notes: a short note each time the outer bob's height passes a level ── { group: "height", key: "heightNotes", label: "height notes", kind: "bool", default: true, hint: "levels are the scale's notes between the low and high pitch (every `step`-th); passing one, up or down, plays it" }, { group: "height", key: "heightInstrument", label: "instrument", kind: "select", default: "modal: Piano-ish", options: Object.keys(NOTE_INSTRUMENTS) }, { group: "height", key: "heightLow", label: "pitch at bottom", kind: "number", default: 60, min: 24, max: 108, step: 0.5, unit: "midi", hint: "bob straight down" }, { group: "height", key: "heightHigh", label: "pitch at top", kind: "number", default: 96, min: 24, max: 120, step: 0.5, unit: "midi", hint: "bob straight up" }, pick("scale", { group: "height", default: "dorian" }), pick("root", { group: "height" }), { group: "height", key: "heightStep", label: "step", kind: "number", default: 2, min: 1, max: 7, step: 1, hint: "levels every this many scale notes (2 = arpeggio-like)" }, { group: "height", key: "heightLength", label: "length", kind: "number", default: 0.3, min: 0.05, max: 3, log: true, unit: "s" }, { group: "height", key: "heightVel", label: "strength", kind: "number", default: 0.7, min: 0.05, max: 1, step: 0.01 }, { group: "height", key: "heightLevel", label: "level", kind: "number", default: 6, min: -48, max: 18, step: 0.5, unit: "dB" }, { group: "height", key: "heightRamp", label: "ramp in", kind: "number", default: 6, min: 0, max: 60, step: 0.5, unit: "s", hint: "the notes grow to full strength over the opening" }, { group: "height", key: "heightRampFrom", label: "ramp from", kind: "number", default: 0.5, min: 0, max: 1, step: 0.01, hint: "starting strength, as a fraction of full" }, { group: "height", key: "heightFollow", label: "fades with energy", kind: "number", default: 0.3, min: 0, max: 2, step: 0.05, hint: "strength × (energy / start energy)^this" }, // ── visual ── { group: "visual", key: "trails", label: "trail", kind: "bool", default: true }, { group: "visual", key: "trailLength", label: "trail length", kind: "number", default: 2.5, min: 0.2, max: 20, log: true, unit: "s" }, { group: "visual", key: "rings", label: "rings", kind: "bool", default: true, hint: "a brief ring where each bottom note (and, smaller, each click) happens" }, pick("motionBlur"), ];