import type { ParamSpec } from "../../core/params.ts"; import { SIGNALS } from "../../lab/protocol.ts"; import { PARTIAL_RATIOS, PITCH_RATIOS } from "./harmony.ts"; // A D-major chord whose partials also land on chord tones: // D2+D3, A2+A3, D3+A3, F♯3+F♯4, A3+A4, D4+A4 (pitch ratio to the base, internal interval) const VOICE_DEFAULTS: [string, string, number, number][] = [ // pitch ratio, partial ratio, shape l2/l1, ring s ["1", "2", 1, 20], ["3/2", "2", 1.3, 18], ["2", "3/2", 0.8, 16], ["5/2", "2", 1.6, 14], ["3", "2", 0.7, 12], ["4", "3/2", 1.2, 10], ]; export const schema: ParamSpec[] = [ { group: "harmony", key: "basePitch", label: "base pitch", kind: "number", default: 73.42, min: 20, max: 1000, log: true, unit: "Hz", hint: "pitch ratio 1 sounds here (D2 by default); all pendulums share one time scale, so each pitch comes from its size" }, { group: "visual", key: "sizeExp", label: "size drawing", kind: "number", default: 0.5, min: 0, max: 1, step: 0.05, hint: "drawn size ∝ length^this (1 = true scale: two octaves = 16× the length)", live: true }, { group: "visual", key: "trail", label: "trail", kind: "number", default: 0.35, min: 0, max: 1, step: 0.01, hint: "opacity of the bobs' recent paths", live: true }, { group: "score", key: "score", label: "score", kind: "text", default: "36 25 36 25 36 25 1!4", hint: "one step per word: the pendulums pushed together (1–6); ! after a digit = accented; . = a rest" }, { group: "score", key: "tempo", label: "tempo", kind: "number", default: 120, min: 10, max: 400, log: true, unit: "bpm" }, { group: "score", key: "stepBeats", label: "step length", kind: "number", default: 4, min: 0.25, max: 16, step: 0.25, unit: "beats", hint: "4 = a whole note per step" }, { group: "score", key: "pulseAdds", label: "push adds", kind: "number", default: 0.08, min: 0.0005, max: 2, log: true, hint: "energy each push adds, in units of E_top" }, { group: "score", key: "accent", label: "accent", kind: "number", default: 4, min: 1, max: 20, log: true, unit: "×", hint: "an accented push (!) adds this many times the energy" }, { group: "score", key: "tail", label: "ring out", kind: "number", default: 16, min: 1, max: 120, log: true, unit: "s", hint: "after the last step, before the end" }, { group: "score", key: "seed", label: "seed", kind: "number", default: 0, min: 0, max: 999999, step: 1, hint: "pushes from rest go in random directions (the mix of each pendulum's two pitches); 0 = a new variation every play" }, { group: "score", key: "fade", label: "fade", kind: "number", default: 6, min: 0.1, max: 60, log: true, unit: "s", hint: "the last part of the ring-out fades to silence" }, { group: "sound", key: "signal", label: "signal", kind: "select", default: "x2", options: [...SIGNALS], hint: "what each pendulum contributes (bob position, velocity, angles…)" }, { group: "sound", key: "gain", label: "gain", kind: "number", default: 0, min: -40, max: 30, step: 0.5, unit: "dB", hint: "per pendulum, before its soft limiter" }, { group: "sound", key: "spread", label: "stereo spread", kind: "number", default: 0.7, min: 0, max: 1, step: 0.01 }, { group: "sound", key: "dcCut", label: "low cut", kind: "number", default: 20, min: 1, max: 500, log: true, unit: "Hz" }, { group: "sound", key: "level", label: "level", kind: "number", default: 0, min: -48, max: 12, step: 0.5, unit: "dB", live: true }, ...VOICE_DEFAULTS.flatMap(([ratio, partial, shape, ring], i): ParamSpec[] => { const g = `pendulum ${i + 1}`; return [ { group: g, key: `ratio${i + 1}`, label: "pitch ratio", kind: "select", default: ratio, options: PITCH_RATIOS, hint: "lower partial = base pitch × this (sets the size)" }, { group: g, key: `partial${i + 1}`, label: "partials", kind: "select", default: partial, options: PARTIAL_RATIOS, hint: "upper/lower partial interval (sets the mass ratio)" }, { group: g, key: `shape${i + 1}`, label: "l2 / l1", kind: "number", default: shape, min: 0.2, max: 5, log: true, hint: "the pendulum's shape" }, { group: g, key: `ring${i + 1}`, label: "ring time", kind: "number", default: ring, min: 0.05, max: 60, log: true, unit: "s" }, { group: g, key: `level${i + 1}`, label: "level", kind: "number", default: -6, min: -48, max: 12, step: 0.5, unit: "dB" }, ]; }), ];