/ music / double-pendulum
Sign in
music / double-pendulum
double-pendulum / src / compositions / c04-crash / schema.ts
73 lines · 8.2 KBBlameHistoryRaw
1import type { ParamSpec } from "../../core/params.ts";
2import { DRONE_INSTRUMENTS, 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: "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), so a folded pendulum sweeping its bob past the pivot is silent" },
34 { group: "crash", key: "crashHigh", label: "pitch at min depth", kind: "number", default: 55, min: 12, max: 108, step: 0.5, unit: "midi", hint: "crossing at the minimum depth (the shallowest that counts)" },
35 { group: "crash", key: "crashCurve", label: "pitch curve", kind: "number", default: 1, min: 0.2, max: 5, log: true },
36 { 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)" },
37 { 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" },
38 { 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" },
39 pick("loudCurve", { group: "crash" }),
40 pick("loudFloor", { group: "crash", default: 0.15 }),
41 pick("notesLevel", { group: "crash", default: -2 }),
42 { 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)" },
43 { 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" },
44 { 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)" },
46 // ── click: the outer bob sweeping past the pivot (within the minimum depth) ──
47 { 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)" },
48 { group: "click", key: "clickInstrument", label: "instrument", kind: "select", default: "modal: Viola", options: Object.keys(NOTE_INSTRUMENTS) },
49 { group: "click", key: "clickPitch", label: "pitch", kind: "number", default: 72, min: 24, max: 120, step: 0.5, unit: "midi" },
50 { group: "click", key: "clickLength", label: "length", kind: "number", default: 0.5, min: 0.01, max: 2, log: true, unit: "s" },
51 { 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 crashes)" },
52 { group: "click", key: "clickLevel", label: "level", kind: "number", default: -4, min: -48, max: 6, step: 0.5, unit: "dB" },
54 // ── voice: a sustained tone whose pitch glides with the outer bob's height ──
55 { group: "voice", key: "voice", label: "height voice", kind: "bool", default: true },
56 { group: "voice", key: "voiceInstrument", label: "instrument", kind: "select", default: "modal: Clarinet-ish", options: ["soft sine", ...Object.keys(DRONE_INSTRUMENTS).filter((k) => k.startsWith("modal: "))], hint: "modal: … = one held modal-synth note, glided with pitch bend (applies on the next play)" },
57 { group: "voice", key: "voiceCustom", label: "modal custom", kind: "text", default: "", hint: "for “modal: custom”: paste JSON from modal-synth’s Copy button" },
58 { group: "voice", key: "voiceTone", label: "tone", kind: "number", default: 0.1, min: 0, max: 1, step: 0.01, hint: "modal voice: 0 = mellow and pure, 1 = bright and reedy (pickup and tilt, as the hum's timbre)" },
59 { 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" },
60 { 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 (modal voices glide at most 24 semitones from the middle)" },
61 { group: "voice", key: "voiceLevel", label: "level", kind: "number", default: -10, min: -60, max: 6, step: 0.5, unit: "dB", hint: "modal voice: held at this loudness (normalized), so it stays comparable to the crashes" },
62 { group: "voice", key: "voiceRamp", label: "ramp in", kind: "number", default: 6, min: 0, max: 60, step: 0.5, unit: "s", hint: "the voice grows to full level over the opening" },
63 { group: "voice", key: "voiceRampFrom", label: "ramp from", kind: "number", default: 0.2, min: 0, max: 1, step: 0.01, hint: "starting level, as a fraction of full" },
64 { 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" },
65 { group: "voice", key: "voiceBright", label: "sine brightness", kind: "number", default: 0.25, min: 0, max: 1, step: 0.01, hint: "soft sine only" },
66 { group: "voice", key: "voiceVibrato", label: "sine vibrato", kind: "number", default: 6, min: 0, max: 40, step: 0.5, unit: "cents", hint: "soft sine only" },
68 // ── visual ──
69 { group: "visual", key: "trails", label: "trail", kind: "bool", default: true },
70 { group: "visual", key: "trailLength", label: "trail length", kind: "number", default: 2.5, min: 0.2, max: 20, log: true, unit: "s" },
71 { group: "visual", key: "crashRings", label: "crash rings", kind: "bool", default: true, hint: "a brief ring where each crash happens" },
72 pick("motionBlur"),
73];
↑↓ move↵openescclose