Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.
TypeScript agent-skillsanimationcanvasclaude-codeclaude-pluginclaude-skillscodex-plugincreative-codecreative-codingcreative-toolsdeterministicgenerative-arthand-drawnillustrationlaunch-videomotion-designmotion-graphicspluginprocedural-generationskill
music: harp fitted to VCSL Concert Harp C3/C5 (CC0) - pluck point, contact width by register, absolute excitation brightness, longer ring; mono lows on the section voices (4th-order side high-pass), spaced-pair delays for brass players; tools/ensemble-check.mjs ref (harmonic spectrum + decay vs a recording) and a stereo check
Alex Greenshpund2964d7b1b5e
diff --git a/skills/anidoodle/engine/src/canvas-core/music/ensemble.ts b/skills/anidoodle/engine/src/canvas-core/music/ensemble.tsindex 02247a7..0d1d1f3 100644--- a/skills/anidoodle/engine/src/canvas-core/music/ensemble.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/ensemble.ts@@ -288,26 +288,27 @@ export const choir = (keys: Played[], sr: number, n: number, o: Opts, r0: Rng):}});Biquad.make(sr, "hp", 70, 0.7).run(out.L); Biquad.make(sr, "hp", 70, 0.7).run(out.R);- return monoLows(out, sr);+ return monoLows(out, sr, 220);};// ------------------------------------------------------------------ plucked strings-type PluckSpec = { width: number; beta: number; noise: number; lpMul: number; loss: number; t60: (f: number) => number; relT60: number; ring: boolean; pol2: number; ir?: IRSpec; pick: number; level: number };+type PluckSpec = { width: number; beta: number; noise: number; lpMul: number; /** absolute excitation low-pass (Hz) instead of lpMul x f */ lpAbs?: number; /** contact width grows as (f / 131 Hz)^widthExp (thicker treble strings, softer finger) */ widthExp?: number; loss: number; t60: (f: number) => number; relT60: number; ring: boolean; pol2: number; ir?: IRSpec; pick: number; level: number };const PLUCK: Record<string, PluckSpec> = {nylon: { width: 0.0022, beta: 0.2, noise: 0.25, lpMul: 3.5, loss: 0.3, t60: (f) => clamp(3.4 * Math.pow(196 / f, 0.55), 0.7, 7), relT60: 0.18, ring: false, pol2: 0.6, ir: IR_NYLON, pick: 0, level: LEVEL.guitar },steel: { width: 0.0007, beta: 0.13, noise: 0.4, lpMul: 9, loss: 0.16, t60: (f) => clamp(4.5 * Math.pow(196 / f, 0.5), 1, 9), relT60: 0.15, ring: false, pol2: 0.7, ir: IR_STEEL, pick: 0.05, level: LEVEL.guitar },electric: { width: 0.0008, beta: 0.12, noise: 0.35, lpMul: 7, loss: 0.14, t60: (f) => clamp(6 * Math.pow(196 / f, 0.45), 1.5, 12), relT60: 0.12, ring: false, pol2: 0.4, pick: 0.035, level: LEVEL.guitar },- harp: { width: 0.003, beta: 0.36, noise: 0.2, lpMul: 3, loss: 0.14, t60: (f) => clamp(4.2 * Math.pow(262 / f, 0.45), 0.8, 8), relT60: 1, ring: true, pol2: 0.5, ir: IR_HARP, pick: 0, level: LEVEL.harp },+ // harp: brightness, pluck point and ring fitted by ear-free A/B to VCSL Concert Harp C3/C5 (CC0; tools/ensemble-check.mjs ref)+ harp: { width: 0.0018, widthExp: 0.35, beta: 0.1, noise: 0.2, lpMul: 3, lpAbs: 900, loss: 0.14, t60: (f) => clamp(9.5 * Math.pow(262 / f, 0.45), 1.5, 16), relT60: 1, ring: true, pol2: 0.5, ir: IR_HARP, pick: 0, level: LEVEL.harp },};/** One plucked note (mono): excitation, commuted body, extended KS, optional pickup comb and pick scrape; RMS-normalised then scaled by velocity. */const pluckNote = (sr: number, n: number, k: Played, s: PluckSpec, r: Rng, extra: { pickup?: number; glide?: { cents: number; tau: number }; thump?: number } = {}) => {const f = f0(k.p) * Math.pow(2, clamp(gn(r) * 1.5, -4, 4) / 1200), v = clamp(k.v * (0.9 + 0.2 * r()), 0.02, 1), T60 = s.t60(f) * (0.92 + 0.16 * r());- let exc = pluckExc(sr, f, { width: s.width * (1.3 - 0.6 * v) * (0.9 + 0.2 * r()), beta: s.beta * (0.88 + 0.24 * r()), noise: s.noise, lp: f * s.lpMul * (0.6 + 0.8 * v) }, r);+ let exc = pluckExc(sr, f, { width: s.width * Math.pow(f / 131, s.widthExp ?? 0) * (1.3 - 0.6 * v) * (0.9 + 0.2 * r()), beta: s.beta * (0.88 + 0.24 * r()), noise: s.noise, lp: (s.lpAbs ? Math.max(f * 1.2, s.lpAbs) : f * s.lpMul) * (0.6 + 0.8 * v) }, r);if (s.ir) exc = convolve(exc, bodyIR(sr, s.ir));const dur = Math.max(0.02, k.off - k.t), relI = s.ring ? Infinity : Math.round(dur * sr), len = Math.max(1, Math.min(n, Math.ceil((s.ring ? T60 * 1.1 : Math.min(T60 * 1.1, dur + s.relT60 * 1.5)) * sr)));const y = ksRender(sr, { f, T60, loss: s.loss * (0.92 + 0.16 * r()), exc, len, relI: relI === Infinity ? len : relI, relT60: s.relT60, pol2: { cents: 0.3 + 0.7 * r(), mix: s.pol2, t60: 0.45, share: r() }, glide: extra.glide });if (extra.pickup) { const D = extra.pickup * (sr / f), Di = Math.floor(D), Df = D - Di; for (let i = len - 1; i >= 0; i--) { const a = i - Di >= 0 ? y[i - Di] : 0, b = i - Di - 1 >= 0 ? y[i - Di - 1] : 0; y[i] -= 0.9 * (a * (1 - Df) + b * Df); } }- const g = (Math.pow(v, 1.3) * clamp(Math.pow(523 / f, s.ring ? 0.8 : 0.5), 0.3, 1.2)) / headRms(y, sr); // high notes of real plucked strings are quieter+ const g = (Math.pow(v, 1.3) * (s.ring ? clamp(Math.pow(523 / f, 0.15), 0.3, 0.9) : clamp(Math.pow(523 / f, 0.5), 0.3, 1.2))) / headRms(y, sr); // high notes of real plucked strings are quieterfor (let i = 0; i < len; i++) y[i] *= g;if (s.pick > 0 || extra.thump) { let lp = 0; const m = Math.min(len, Math.round(0.02 * sr)), kLp = extra.thump ? 0.03 : 0.5;for (let i = 0; i < m; i++) { const nz = wn(r); lp += kLp * (nz - lp); const e = Math.exp(-i / (0.003 * sr)); y[i] += (extra.thump ? lp * extra.thump * 4 : (nz - lp) * s.pick * 3) * e * v; } }diff --git a/skills/anidoodle/engine/tools/ensemble-check.mjs b/skills/anidoodle/engine/tools/ensemble-check.mjsindex 47d5d2b..7f477cd 100644--- a/skills/anidoodle/engine/tools/ensemble-check.mjs+++ b/skills/anidoodle/engine/tools/ensemble-check.mjs@@ -3,6 +3,7 @@// node tools/ensemble-check.mjs check tuning (cents), anti-clone, determinism, stereo, legacy bit-identity// node tools/ensemble-check.mjs calibrate stem RMS of every vocabulary slot that uses an ensemble voice, v2 vs legacy// node tools/ensemble-check.mjs track <voice> [opts-json] per-note pitch through a legato phrase (octave slips, level)+// node tools/ensemble-check.mjs ref <voice> <opts-json> <midi> <file.wav> harmonic spectrum + decay vs a CC0 recording, v1 and v2// node tools/ensemble-check.mjs render <dir> before-*.mp3 (legacy) / after-*.mp3 (v2): a phrase per instrument + an ensemble passageimport { strict as assert } from "node:assert";import { build } from "esbuild";@@ -161,3 +162,17 @@ if (cmd === "track") {console.log(` ${name} p ${k.p}: period ${bl} vs ${P.toFixed(1)} (${(1200 * Math.log2(bl / P)).toFixed(0)} c) r ${best.toFixed(2)} ${(20 * Math.log10(rms)).toFixed(1)} dB`);}}++if (cmd === "ref") {+ const [name, oj, midiS, file] = process.argv.slice(3), o = JSON.parse(oj), p = Number(midiS), sr = 48000, f = 440 * 2 ** ((p - 69) / 12);+ const raw = execFileSync("ffmpeg", ["-v", "error", "-i", file, "-ac", "1", "-ar", String(sr), "-f", "f32le", "-"], { maxBuffer: 1 << 28 }), ref = new Float32Array(raw.buffer, raw.byteOffset, raw.length / 4);+ const n = Math.round(3 * sr), mk = (legacy) => { const r = VOICE[name]([key(0.05, p, 2.5, 0.6)], sr, n, { ...o, ...(legacy ? { legacy: true } : {}) }, 4), x = new Float32Array(n); for (let i = 0; i < n; i++) x[i] = r.L[i] + r.R[i]; return x; };+ const prof = (x) => { let pk = 0; for (const v of x) pk = Math.max(pk, Math.abs(v)); let i0 = 0; while (i0 < x.length && Math.abs(x[i0]) < pk * 0.03) i0++;+ const amp = (h, a, b) => { let re = 0, im = 0; const w = (2 * Math.PI * f * h) / sr; for (let i = a; i < b && i < x.length; i++) { const hn = 0.5 - 0.5 * Math.cos((2 * Math.PI * (i - a)) / (b - a)); re += x[i] * hn * Math.cos(w * i); im += x[i] * hn * Math.sin(w * i); } return Math.hypot(re, im) + 1e-12; };+ const a = i0 + Math.round(0.05 * sr), b = i0 + Math.round(0.35 * sr), h1 = amp(1, a, b), spec = Array.from({ length: 10 }, (_, k) => 20 * Math.log10(amp(k + 1, a, b) / h1));+ const e = (t0) => 20 * Math.log10(amp(1, i0 + Math.round(t0 * sr), i0 + Math.round((t0 + 0.2) * sr))), decay = (e(0.1) - e(0.9)) / 0.8;+ return { spec, decay }; };+ const R = prof(ref), A = prof(mk(true)), B = prof(mk(false)), dist = (X) => X.spec.slice(1).reduce((s, v, i) => s + Math.abs(Math.max(v, -60) - Math.max(R.spec[i + 1], -60)), 0) / 9;+ const row = (nm, X) => console.log(` ${nm.padEnd(6)} h2..h10 dB ${X.spec.slice(1).map((v) => Math.max(-60, v).toFixed(0).padStart(4)).join("")} fundamental decay ${X.decay.toFixed(1)} dB/s${X === R ? "" : ` |spectrum - ref| ${dist(X).toFixed(1)} dB`}`);+ console.log(` ${name} ${oj} midi ${p} vs ${file.split("/").pop()}`); row("ref", R); row("v1", A); row("v2", B);+}