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
sfx: a fractional cue frame is rejected (documented); the demo's typing ticks sit on whole frames
Alex Greenshpunfe1c68f7704f
diff --git a/skills/anidoodle/engine/src/canvas-core/music/sfxMix.ts b/skills/anidoodle/engine/src/canvas-core/music/sfxMix.tsindex aa75d4a..d756727 100644--- a/skills/anidoodle/engine/src/canvas-core/music/sfxMix.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/sfxMix.ts@@ -11,7 +11,7 @@ import { loudness, truePeak } from "./meter";export type SfxSnap = "none" | "bar" | "beat" | "8th" | "16th";export type SfxCue = SfxOpts & {- /** the frame the sound's sync point lands on (the hit; the pass-by of a whoosh; the END of a riser). */+ /** the whole frame the sound's sync point lands on (the hit; the pass-by of a whoosh; the END of a riser). A fractional frame throws. */frame: number; kind: SfxKind; label?: string;/** snap the sync point to the beat grid (needs plan.bpm). Default: plan.snap ?? "none". */snap?: SfxSnap;@@ -64,6 +64,7 @@ export const validateSfxPlan = (plan: SfxPlan) => {if (!c || typeof c !== "object") throw new Error(`sfx plan: cue #${i} is not an object`);if (!(c.kind in SFX)) throw new Error(`sfx plan: cue #${i} has unknown kind "${String(c.kind)}" (kinds: ${SFX_KINDS.join(", ")})`);if (typeof c.frame !== "number" || !Number.isFinite(c.frame) || c.frame < 0 || c.frame >= p.frames) throw new Error(`sfx plan: ${name(c, i)}: frame must be 0..${p.frames - 1}`);+ if (!Number.isInteger(c.frame)) throw new Error(`sfx plan: ${name(c, i)}: frame must be a whole frame (cues are addressed by the frame the picture shows; for a hit between frames, snap it to the beat grid)`);const snap = c.snap ?? p.snap ?? "none";if (!(snap === "none" || snap in GRID)) throw new Error(`sfx plan: ${name(c, i)}: snap must be none|bar|beat|8th|16th`);if ((snap !== "none" || c.beats !== undefined) && p.bpm === undefined && c.bpm === undefined) throw new Error(`sfx plan: ${name(c, i)}: snap/beats need a bpm (plan.bpm)`);diff --git a/skills/anidoodle/engine/tools/sfx.mjs b/skills/anidoodle/engine/tools/sfx.mjsindex 719d44e..1fb4e2f 100644--- a/skills/anidoodle/engine/tools/sfx.mjs+++ b/skills/anidoodle/engine/tools/sfx.mjs@@ -65,9 +65,9 @@ const baseline = (M) => {const FPS = 30, DEMO_FRAMES = 450;export const demoPlan = (M) => {const cues = [];- // typing "make a koi that swims" at a human cadence+ // typing "make a koi that swims" at a human cadence (a cue sits on a whole frame)const text = "make a koi that swims"; let f = 12;- for (let i = 0; i < text.length; i++) { cues.push({ frame: f, kind: "tick", variant: text[i] === " " ? "space" : "key", label: i === 0 ? "typing" : undefined }); f += 2.4 + ((i * 7) % 5) * 0.55 + (text[i] === " " ? 1.5 : 0); }+ for (let i = 0; i < text.length; i++) { cues.push({ frame: Math.round(f), kind: "tick", variant: text[i] === " " ? "space" : "key", label: i === 0 ? "typing" : undefined }); f += 2.4 + ((i * 7) % 5) * 0.55 + (text[i] === " " ? 1.5 : 0); }cues.push({ frame: 157, kind: "press", variant: "thock", snap: "beat", label: "Generate" },{ frame: 170, kind: "ink", variant: "bloom", label: "the drawing opens" },@@ -165,6 +165,7 @@ const test = async () => {throws(() => M.renderSfx("riser", { key: "C" }), /needs a bpm.*no default tempo/, "riser without a bpm");ok(M.renderSfx("press", {}).L.length > 0 && M.renderSfx("riser", { variant: "air", lengthS: 2 }).L.length > 0, "untuned kinds render without key/bpm");throws(() => M.mixSfx(null, { fps: 30, frames: 300, cues: [{ frame: 10, kind: "chime" }] }, SR), /cue #0 \(chime.*is tuned: set plan.key/, "plan cue: chime without a key names the cue");+ throws(() => M.mixSfx(null, { fps: 30, frames: 300, cues: [{ frame: 10.5, kind: "tick" }] }, SR), /cue #0 \(tick.*must be a whole frame/, "a fractional cue frame is rejected, not rounded");const noct = M.nocturne(), fromScore = M.placeSfx({ fps: 30, frames: 300, score: { piece: noct }, cues: [{ frame: 10, kind: "chime", variant: "bell" }, { frame: 200, kind: "riser", beats: 2 }] }, SR);const rp = M.resolveSfxPlan({ fps: 30, frames: 300, score: { piece: noct }, cues: [] });ok(rp.key === "Ab" && rp.bpm === noct.plan.tempo && rp.beatsPerBar === 3, `plan.score gives key/bpm/bar (got ${rp.key} ${rp.bpm} ${rp.beatsPerBar})`);diff --git a/skills/anidoodle/references/music/sound-design.md b/skills/anidoodle/references/music/sound-design.mdindex 8106e06..27f1def 100644--- a/skills/anidoodle/references/music/sound-design.md+++ b/skills/anidoodle/references/music/sound-design.md@@ -49,7 +49,8 @@ speaking window (K-weighted, see below). Duck is how far the score dips under it## Placing effects in a film-Cues are addressed by **film frame**. The frame is where the sound's sync point lands: the hit;+Cues are addressed by **film frame**, a whole number (a fractional frame throws; to land a hit+between frames, `snap` it to the beat). The frame is where the sound's sync point lands: the hit;the pass-by of a whoosh; the landing of a paper slide; the END of a riser. Pre-roll (a whoosh'sapproach, a riser's build) is rendered before the frame. If it would start before frame 0,the plan throws and names the earliest legal frame.