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: one source of feel. perform.ts (S1 FEELS, keyed by style) places every drum key; drums.ts no longer adds its per-kit lane offsets and hat drift on top. Measured (lofi test piece, grid -> audible onset): snare 34.6 -> 16.0 ms, ghost 20.4 -> 8.3; key -> audio offset now 0-1 ms on every lane (was +17 snare, +11 ghost dusty). Biquad corners held at 0.45 sr: a 17.5 kHz hat low-pass or the sampler's 11 kHz filter at a 16 kHz render went unstable (NaN mix, the launchTemplate bed read -200 LUFS)
Alex Greenshpun11617e2f4ed8
diff --git a/skills/anidoodle/engine/src/canvas-core/music/drums.ts b/skills/anidoodle/engine/src/canvas-core/music/drums.tsindex e12a71f..386749a 100644--- a/skills/anidoodle/engine/src/canvas-core/music/drums.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/drums.ts@@ -48,14 +48,9 @@ export const kitOf = (o: Opts, style?: string): KitId => (typeof o.kit === "stri/** Audience-view placement, -1 left .. 1 right. */const PAN: Record<DrumPiece, number> = { kick: 0, snare: 0.06, rimshot: 0.06, ghost: 0.06, cross: 0.08, clap: 0, hat: 0.34, open: 0.34, pedal: 0.3, ride: -0.38, bell: -0.38, crash: 0.42,tomHi: 0.2, tomMid: -0.05, tomLo: -0.32, shaker: -0.45, tamb: 0.5, brush: 0.06, sweep: 0.06, dum: -0.1, tek: 0.15, ka: 0.3, cowbell: -0.2 };-type Lane = "kick" | "snare" | "ghost" | "hat" | "perc";-const LANE: Record<DrumPiece, Lane> = { kick: "kick", snare: "snare", rimshot: "snare", clap: "snare", ghost: "ghost", cross: "ghost", brush: "ghost", sweep: "ghost", hat: "hat", open: "hat", pedal: "hat", ride: "hat", bell: "hat",- crash: "perc", tomHi: "perc", tomMid: "perc", tomLo: "perc", shaker: "perc", tamb: "perc", dum: "kick", tek: "ghost", ka: "perc", cowbell: "perc" };-/** Microtiming per lane in ms (mean, then the hat lane's 1/f drift sigma): kick on the grid, the snare lays back, hats push. Machines sit on the grid. */-const FEEL: Record<KitId, Record<Lane, number> & { drift: number }> = {- acoustic: { kick: 0, snare: 4, ghost: 2, hat: -3, perc: 0, drift: 3 }, "808": { kick: 0, snare: 6, ghost: 4, hat: -1, perc: 2, drift: 1.5 }, "909": { kick: 0, snare: 0, ghost: 0, hat: 0, perc: 0, drift: 0 },- dusty: { kick: 0, snare: 17, ghost: 11, hat: 3, perc: 7, drift: 5 }, brush: { kick: 0, snare: 5, ghost: 4, hat: -6, perc: 2, drift: 4 }, orch: { kick: 0, snare: 2, ghost: 2, hat: 0, perc: 0, drift: 2 },-};+// Microtiming is NOT here: perform.ts owns the feel (mixProfiles FEELS, keyed by the style: lane offsets, humanize,+// jitter, hat drift) and hands the kit keys that are already placed. A kit adding its own offsets doubled them (the+// dusty snare landed 35 ms late instead of 18; measured at the sound-v2 merge).// ---------------------------------------------------------------- building blockstype Var = { g: number; tune: number; dec: number; bright: number; ph: number; wire: number };@@ -303,9 +298,8 @@ export const chokeTimes = (parts: { inst: string; opts?: Opts; keys: Played[] }[/** A kit voice: kick / snare / hat lanes (the inst gives the lane's default piece). */export const kitVoice = (inst: string, keys: Played[], sr: number, n: number, o: Opts, r: Rng, ctx: KitCtx = {}): Out => {- const kit = kitOf(o, ctx.style), L = new Float32Array(n), R = new Float32Array(n), F = FEEL[kit], grid = o.grid === true, choke = ctx.choke ?? [];+ const kit = kitOf(o, ctx.style), L = new Float32Array(n), R = new Float32Array(n), choke = ctx.choke ?? [];const width = typeof o.width === "number" ? (o.width as number) : 1;- let drift = 0;const put = (y: Buf | [Buf, Buf], t: number, p: number, g: number) => {const i0 = Math.round(t * sr); if (i0 >= n) return;const [gl, gr] = pan(p * width);@@ -317,9 +311,7 @@ export const kitVoice = (inst: string, keys: Played[], sr: number, n: number, o:if (kit === "brush" && (pc === "snare" || pc === "ghost" || pc === "cross" || pc === "rimshot")) pc = "brush";if (kit !== "brush" && pc === "sweep") pc = "shaker";if (kit !== "brush" && pc === "brush") pc = "ghost";- const lane = LANE[pc];- let t = k.t;- if (!grid) { if (lane === "hat") drift = 0.8 * drift + 0.6 * gauss(r) * F.drift; t = Math.max(0, t + (F[lane] + (lane === "hat" ? drift : 0)) / 1000); }+ const t = k.t;const x = vary(r), v = clamp(k.v, 0.02, 1), dur = Math.max(0.02, k.off - k.t), rolled = o.roll === true || k.kind === "roll", g = x.g * (TRIM[pc] ?? 0.5) * lvl(kit, pc), p = PAN[pc] + (r() - 0.5) * 0.04;switch (pc) {case "kick":diff --git a/skills/anidoodle/engine/src/canvas-core/music/dsp.ts b/skills/anidoodle/engine/src/canvas-core/music/dsp.tsindex 55bda99..a482c26 100644--- a/skills/anidoodle/engine/src/canvas-core/music/dsp.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/dsp.ts@@ -21,7 +21,8 @@ export class SVF {export class Biquad {private x1 = 0; private x2 = 0; private y1 = 0; private y2 = 0; b0 = 1; b1 = 0; b2 = 0; a1 = 0; a2 = 0;static make(sr: number, type: "lp" | "hp" | "bp" | "peak" | "lowshelf" | "highshelf", f: number, q: number, gainDb = 0) {- const bq = new Biquad(), w = (TAU * f) / sr, c = Math.cos(w), s = Math.sin(w), al = s / (2 * q), A = Math.pow(10, gainDb / 40);+ // a corner at or past Nyquist is not a filter (the coefficients go unstable: NaN at 16 kHz for a 17.5 kHz low-pass); hold it at 0.45 sr+ const bq = new Biquad(), w = (TAU * Math.min(f, 0.45 * sr)) / sr, c = Math.cos(w), s = Math.sin(w), al = s / (2 * q), A = Math.pow(10, gainDb / 40);let b0 = 1, b1 = 0, b2 = 0, a0 = 1, a1 = 0, a2 = 0;if (type === "lp") { b0 = (1 - c) / 2; b1 = 1 - c; b2 = b0; a0 = 1 + al; a1 = -2 * c; a2 = 1 - al; }else if (type === "hp") { b0 = (1 + c) / 2; b1 = -(1 + c); b2 = b0; a0 = 1 + al; a1 = -2 * c; a2 = 1 - al; }