// Shared between the lab page and the pendulum-voice worklet. export const SIGNALS = ["x2", "y2", "vx2", "vy2", "x1", "vx1", "θ1", "θ2", "θ2−θ1", "ω1", "ω2", "p1", "p2", "speed2"] as const; export type Signal = (typeof SIGNALS)[number]; export interface LabSettings { mode: "strike" | "sustain" | "swell"; pitch: number; // Hz of the lower small-swing mode energy: number; // normalized (E / E_top): sustain level, swell target strikeEnergy: number; // normalized energy each strike adds ringTime: number; // s (audio): amplitude falls 60 dB, without the energy controller restrike: number; // s between strikes / swells (0 = once) swellTime: number; // s massRatio: number; lengthRatio: number; left: Signal; right: Signal; gain: number; // linear dcCut: number; // Hz follow: number; // sustain/swell: energy controller time constant, in periods of the lower mode } export type LabMsg = { type: "settings"; s: LabSettings } | { type: "strike" }; export interface LabSnap { type: "snap"; energy: number; phase: string; trail: Float32Array; // recent bob positions [x1, y1, x2, y2, …] (pendulum units) k: number; // sim seconds per audio second } // ── ensemble lab ── export const ENSEMBLE = 6; export interface EnsembleVoice { // physics (computed on the page from the musical ratios: see c05-ensemble/harmony.ts) l1: number; l2: number; m2: number; // m1 = 1, g = 1 upperHz: number; // the faster mode's pitch at small swings (sets the integration step) ringTime: number; // s: amplitude −60 dB level: number; // linear } export interface EnsembleSettings { voices: EnsembleVoice[]; k: number; // sim seconds per audio second (one time scale for all: pitch comes from size) pulseAdds: number; // normalized energy a key push adds /** the score: step k (at startDelay + k·stepSec) pushes these pendulums by these energies */ score: { i: number; add: number }[][]; stepSec: number; startDelay: number; // s seed: number; // the random push directions from rest (a new one each play) signal: Signal; gain: number; // linear, before the soft limiter dcCut: number; // Hz spread: number; // 0..1 stereo spread } export type EnsembleMsg = | { type: "settings"; s: EnsembleSettings } | { type: "strike"; i: number } | { type: "reset" }; export interface EnsembleSnap { type: "snap"; time: number; // s since the score began (audio clock) step: number; // score steps played so far energy: number[]; // normalized, per pendulum trails: Float32Array; // per pendulum: TRAIL × [x2, y2] (oldest → newest), physical units joints: Float32Array; // per pendulum, now: [x1, y1, x2, y2] struck: number[]; // per pendulum: s since its last push (beat or key) }