/ music / double-pendulum
Sign in
music / double-pendulum
double-pendulum / src / compositions / c04-crash / schema.ts
59 lines · 5.7 KBBlameHistoryRaw
1import type { ParamSpec } from "../../core/params.ts";
2import { NOTE_INSTRUMENTS } from "../../instruments/index.ts";
3import { schema as c01 } from "../c01-poincare/schema.ts";
5const pick = (key: string, o: Partial<ParamSpec> = {}): ParamSpec => {
6 const s = c01.find((x) => x.key === key);
7 if (!s) throw new Error(`no setting ${key} in composition 1`);
8 return { ...s, ...o } as ParamSpec;
9};
11export const schema: ParamSpec[] = [
12 // ── form ──
13 { 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" },
14 { 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" },
15 { 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" },
16 { 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)" },
17 { 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" },
18 pick("restEnergy", { hint: "after the damping, the pendulum counts as at rest below this energy: the last crash rings out" }),
19 pick("finalHold"),
20 pick("finalFade"),
22 // ── pendulum ──
23 { 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" },
24 { 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" },
25 pick("massRatio", { group: "pendulum" }),
26 pick("lengthRatio", { group: "pendulum" }),
27 pick("seed", { group: "pendulum", hint: "0 = a different nudge (side and shape) every play" }),
29 // ── crashes: outer bob crossing the vertical below the pivot ──
30 { group: "crash", key: "crashInstrument", label: "instrument", kind: "select", default: "modal: Chaos gong", options: Object.keys(NOTE_INSTRUMENTS) },
31 pick("modalCustom", { group: "crash" }),
32 { group: "crash", key: "crashLow", label: "pitch at bottom", kind: "number", default: 31, min: 12, max: 96, step: 0.5, unit: "midi", hint: "crossing with the bob straight down (continuous pitch)" },
33 { group: "crash", key: "crashHigh", label: "pitch at pivot level", kind: "number", default: 55, min: 12, max: 108, step: 0.5, unit: "midi", hint: "crossing with the bob up at the pivot's height" },
34 { group: "crash", key: "crashCurve", label: "pitch curve", kind: "number", default: 1, min: 0.2, max: 5, log: true },
35 { group: "crash", key: "firstVel", label: "first crash", kind: "number", default: 1, min: 0.05, max: 1, step: 0.01, hint: "strength of the first crash (accent)" },
36 { group: "crash", key: "maxVel", label: "strongest crash", kind: "number", default: 0.6, min: 0.05, max: 1, step: 0.01, hint: "strength of later crashes at full speed" },
37 { group: "crash", 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 crash" },
38 pick("loudCurve", { group: "crash" }),
39 pick("loudFloor", { group: "crash", default: 0.15 }),
40 pick("notesLevel", { group: "crash", default: -2 }),
41 { group: "crash", key: "maxCrashes", label: "overlapping crashes", kind: "number", default: 4, min: 1, max: 16, step: 1, hint: "most crashes ringing at once (a new one replaces the oldest)" },
42 { group: "crash", key: "deviceLimit", label: "limit to device", kind: "bool", default: true, hint: "measure (once per device) how many ringing crashes it can render, and allow no more" },
43 { group: "crash", key: "streamAudio", label: "render ahead", kind: "bool", default: true, hint: "render the crashes in a background thread, ~1 s ahead (applies on the next play)" },
45 // ── voice: a soft high tone whose pitch is the outer bob's height ──
46 { group: "voice", key: "voice", label: "height voice", kind: "bool", default: true },
47 { group: "voice", key: "voiceLow", label: "pitch at bottom", kind: "number", default: 67, min: 36, max: 108, step: 0.5, unit: "midi", hint: "bob straight down" },
48 { group: "voice", key: "voiceHigh", label: "pitch at top", kind: "number", default: 91, min: 36, max: 120, step: 0.5, unit: "midi", hint: "bob straight up" },
49 { group: "voice", key: "voiceLevel", label: "level", kind: "number", default: -32, min: -60, max: 0, step: 0.5, unit: "dB" },
50 { group: "voice", key: "voiceBright", label: "brightness", kind: "number", default: 0.25, min: 0, max: 1, step: 0.01 },
51 { group: "voice", key: "voiceVibrato", label: "vibrato", kind: "number", default: 6, min: 0, max: 40, step: 0.5, unit: "cents" },
52 { group: "voice", key: "voiceFollow", label: "fades with energy", kind: "number", default: 0.5, min: 0, max: 2, step: 0.05, hint: "level × (energy / start energy)^this, so it quiets as the pendulum is damped" },
54 // ── visual ──
55 { group: "visual", key: "trails", label: "trail", kind: "bool", default: true },
56 { group: "visual", key: "trailLength", label: "trail length", kind: "number", default: 2.5, min: 0.2, max: 20, log: true, unit: "s" },
57 { group: "visual", key: "crashRings", label: "crash rings", kind: "bool", default: true, hint: "a brief ring where each crash happens" },
58 pick("motionBlur"),
59];
↑↓ move↵openescclose