5c043e1Add composition 2: orbitsJeremy Magland 1import type { ParamSpec } from "../../core/params.ts";
2import { NOTE_INSTRUMENTS } from "../../instruments/index.ts";
3import { schema as c01 } from "../c01-poincare/schema.ts";
5// Composition 2 shares most settings with composition 1 (same meanings and ranges).
6const pick = (key: string, o: Partial<ParamSpec> = {}): ParamSpec => {
7 const s = c01.find((x) => x.key === key);
8 if (!s) throw new Error(`no setting ${key} in composition 1`);
9 return { ...s, ...o } as ParamSpec;
10};
12export const SLOTS = 6;
13const SLOT_DEFAULTS: [string, number][] = [
14 ["modal: Nylon harp", 0],
15 ["modal: Marimba", -1],
16 ["modal: Vibraphone", 0],
17 ["modal: Church bell", -1],
18 ["modal: Steel-string pluck", 0],
19 ["modal: Glass harmonics", 1],
20];
22export const schema: ParamSpec[] = [
23 // ── form ──
24 ...["duration", "peakTime", "holdTime", "energyStart"].map((k) => pick(k)),
25 pick("energyPeak", { default: 0.4 }),
26 ...["riseShape", "riseCurve", "fallCurve", "restEnergy", "finalHold", "finalFade"].map((k) => pick(k)),
28 // ── physics ──
5c043e1Add composition 2: orbitsJeremy Magland 30 ...["massRatio", "lengthRatio", "tau", "seed"].map((k) => pick(k)),
32 // ── orbits ──
216afddorbits: render instruments ahead in Web WorkersJeremy Magland 33 { group: "orbits", key: "streamAudio", label: "render ahead", kind: "bool", default: true, hint: "render each instrument in its own background thread, ~1 s ahead of playback (uses more cores, no glitches from momentary slowdowns); applies on the next play" },
8a22646orbits: limit the orbit count to what the device can play liveJeremy Magland 34 { group: "orbits", key: "deviceLimit", label: "limit to device", kind: "bool", default: true, hint: "measure (once per device) how many orbits this device can play live, and play no more than that" },
2b58483orbits: default 15 orbits at speed 40Jeremy Magland 35 { group: "orbits", key: "orbitCount", label: "orbits", kind: "number", default: 15, min: 1, max: 20, step: 1, hint: "pendulums, all following the same energy; each starts at a random place" },
37 group: "orbits", key: "colors", label: "colors", kind: "text",
38 default: "#d6b37a, #7fa8cf, #c48bb8, #93bf8a, #d48f7f, #a9a6e0",
39 hint: "comma-separated CSS colors; orbit n uses color n (cycling)",
40 },
41 ...Array.from({ length: SLOTS }, (_, i): ParamSpec[] => [
42 {
43 group: "orbits", key: `slot${i + 1}Instrument`, label: `instrument ${i + 1}`, kind: "select",
44 default: SLOT_DEFAULTS[i][0], options: Object.keys(NOTE_INSTRUMENTS),
45 hint: `orbits ${i + 1}, ${i + 1 + SLOTS}, ${i + 1 + 2 * SLOTS}, … play this instrument`,
46 },
47 { group: "orbits", key: `slot${i + 1}Octave`, label: `octave ${i + 1}`, kind: "number", default: SLOT_DEFAULTS[i][1], min: -3, max: 3, step: 1, hint: "register shift for this instrument" },
48 ]).flat(),
49 pick("modalCustom", { group: "orbits", hint: "for “modal: custom” in any slot: paste JSON from modal-synth’s Copy button" }),
79e1f25orbits: lighter on phones (faster engine, shared reverb, cached drawing)Jeremy Magland 50 { group: "orbits", key: "reverbTime", label: "reverb time", kind: "number", default: 3.5, min: 0.3, max: 12, log: true, unit: "s", hint: "one reverb shared by all the orbit instruments (each sends its preset's reverb amount); applies on the next play" },
5c043e1Add composition 2: orbitsJeremy Magland 51
52 // ── notes (one per crossing, per orbit) ──
53 pick("scale", { default: "dorian" }),
54 ...["root", "pitchSource", "thetaRange", "pitchLow", "pitchHigh", "pitchCurve", "invertPitch", "p2Ref", "loudCurve", "loudFloor", "notesLevel", "noteLength", "panAmount"].map((k) => pick(k)),
56 // ── hum ──
57 ...c01.filter((s) => s.group === "hum"),
59 // ── visual ──
01b86bforbits: show the section portrait and each pendulum's traced orbitJeremy Magland 60 pick("fade", { default: 20, hint: "how long each live crossing dot stays visible" }),
5c043e1Add composition 2: orbitsJeremy Magland 61 ...["plotZoom", "zoomSmooth", "plotP"].map((k) => pick(k)),
62 pick("pointSize", { default: 2.5 }),
64 // ── portrait: computed at frozen energy, refreshed (crossfading) as the energy moves ──
65 pick("orbits", { key: "portrait", group: "portrait", label: "show portrait", hint: "grey background: the section's structure at the current energy" }),
66 pick("orbitCount", { key: "portraitCount", group: "portrait" }),
67 pick("orbitCpu", { key: "portraitCpu", group: "portrait" }),
68 pick("orbitLife", { key: "portraitLife", group: "portrait" }),
69 pick("orbitBand", { key: "portraitBand", group: "portrait" }),
70 pick("orbitMinHold", { key: "portraitMinHold", group: "portrait" }),
71 pick("orbitMaxPoints", { key: "portraitMaxPoints", group: "portrait" }),
72 pick("orbitXfade", { key: "portraitXfade", group: "portrait" }),
73 pick("orbitAlpha", { key: "portraitAlpha", group: "portrait", default: 0.15 }),
74 pick("orbitSize", { key: "portraitSize", group: "portrait" }),
75 { group: "portrait", key: "traces", label: "trace orbits", kind: "bool", default: true, hint: "with each portrait, follow every pendulum from its current state (energy frozen) and draw the orbit it's on, in its color" },
76 { group: "portrait", key: "traceMax", label: "trace length", kind: "number", default: 1500, min: 50, max: 10000, log: true, hint: "crossings computed per orbit trace" },
77 { group: "portrait", key: "traceAlpha", label: "trace brightness", kind: "number", default: 0.75, min: 0.02, max: 1, step: 0.01 },
78 { group: "portrait", key: "traceSize", label: "trace point size", kind: "number", default: 1.5, min: 0.5, max: 4, step: 0.1, unit: "px" },