/ music / double-pendulum
Sign in
music / double-pendulum
double-pendulum / src / compositions / c03-divergence / schema.ts
57 lines · 5.2 KBCodeBlameHistory
bc546ddAdd composition 3: divergenceJeremy Magland 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: "freeTime", label: "swinging", kind: "number", default: 40, min: 5, max: 600, step: 1, unit: "s", hint: "free (undamped) swinging before the damping begins" },
14 { 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" },
15 { 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" },
16 { 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" },
17 pick("restEnergy", { hint: "after the damping, a pendulum counts as at rest below this energy: its last note rings out" }),
18 pick("finalHold"),
19 pick("finalFade"),
21 // ── pendulums ──
22 { group: "pendulums", key: "count", label: "pendulums", kind: "number", default: 12, min: 1, max: 24, step: 1 },
23 { 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" },
24 { 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)" },
25 { 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" },
26 { 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" },
27 { 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" },
28 pick("massRatio", { group: "pendulums" }),
29 pick("lengthRatio", { group: "pendulums" }),
30 pick("seed", { group: "pendulums", hint: "0 = a different release every play" }),
32 // ── notes: one per crossing of the vertical by a bottom bob ──
33 { group: "notes", key: "instrument", label: "instrument", kind: "select", default: "modal: Vibraphone", options: Object.keys(NOTE_INSTRUMENTS) },
34 pick("modalCustom"),
35 { 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" },
d5df914divergence: different chords for left-to-right and right-to-left crossingsJeremy Magland 36 { 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" },
bc546ddAdd composition 3: divergenceJeremy Magland 37 pick("scale", { default: "dorian" }),
38 pick("root"),
39 pick("pitchLow", { default: 50 }),
40 pick("pitchHigh", { default: 86 }),
41 { 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)" },
42 pick("loudCurve"),
43 pick("loudFloor"),
44 pick("notesLevel", { default: -8 }),
45 pick("noteLength", { default: 2 }),
46 { 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" },
47 { 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" },
97bd308Make streamed audio robust: voice caps, 2 s buffer, soft underrunsJeremy Magland 48 { 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)" },
50 // ── visual ──
51 { group: "visual", key: "trails", label: "trails", kind: "bool", default: true },
52 { group: "visual", key: "trailLength", label: "trail length", kind: "number", default: 3, min: 0.2, max: 20, log: true, unit: "s" },
53 { group: "visual", key: "trailWidth", label: "trail width", kind: "number", default: 1.2, min: 0.3, max: 5, step: 0.1, unit: "px" },
54 { group: "visual", key: "armAlpha", label: "arm opacity", kind: "number", default: 0.75, min: 0.05, max: 1, step: 0.01 },
55 { group: "visual", key: "bobSize", label: "bob size", kind: "number", default: 3, min: 0.5, max: 10, step: 0.1, unit: "px" },
56 { group: "visual", key: "saturation", label: "color saturation", kind: "number", default: 35, min: 0, max: 100, step: 1, unit: "%" },
57];
↑↓ move↵openescclose