d8370f3Lab: the double pendulum as an instrument (#/lab/edit)Jeremy Magland 1// Shared between the lab page and the pendulum-voice worklet.
3export const SIGNALS = ["x2", "y2", "vx2", "vy2", "x1", "vx1", "θ1", "θ2", "θ2−θ1", "ω1", "ω2", "p1", "p2", "speed2"] as const;
4export type Signal = (typeof SIGNALS)[number];
6export interface LabSettings {
7 mode: "strike" | "sustain" | "swell";
8 pitch: number; // Hz of the lower small-swing mode
9c7f20bLab: strikes add energy to the current motion instead of restartingJeremy Magland 9 energy: number; // normalized (E / E_top): sustain level, swell target
10 strikeEnergy: number; // normalized energy each strike adds
d8370f3Lab: the double pendulum as an instrument (#/lab/edit)Jeremy Magland 11 ringTime: number; // s (audio): amplitude falls 60 dB, without the energy controller
12 restrike: number; // s between strikes / swells (0 = once)
13 swellTime: number; // s
14 massRatio: number;
15 lengthRatio: number;
16 left: Signal;
17 right: Signal;
18 gain: number; // linear
19 dcCut: number; // Hz
20 follow: number; // sustain/swell: energy controller time constant, in periods of the lower mode
21}
23export type LabMsg = { type: "settings"; s: LabSettings } | { type: "strike" };
25export interface LabSnap {
26 type: "snap";
27 energy: number;
28 phase: string;
29 trail: Float32Array; // recent bob positions [x1, y1, x2, y2, …] (pendulum units)
30 k: number; // sim seconds per audio second
31}