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
chore: bump version to 0.7.2
Alex Greenshpun746ad727293a
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonindex 02addb6..401aaab 100644--- a/.claude-plugin/marketplace.json+++ b/.claude-plugin/marketplace.json@@ -13,7 +13,7 @@"name": "anidoodle","source": "./","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with scores composed in code.",- "version": "0.7.1",+ "version": "0.7.2","author": {"name": "Alex Greenshpun","url": "https://linkedin.com/in/alexgreensh"diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 4f72dec..a7fc0c1 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -2,7 +2,7 @@"name": "anidoodle","displayName": "anidoodle","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with scores composed in code.",- "version": "0.7.1",+ "version": "0.7.2","icon": "./assets/icon.png","author": {"name": "Alex Greenshpun",diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 2550d8a..2541ac0 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "anidoodle",- "version": "0.7.1",+ "version": "0.7.2","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with scores composed in code.","skills": "./skills/","interface": {diff --git a/.grok-plugin/marketplace.json b/.grok-plugin/marketplace.jsonindex 254c23b..ee68e6b 100644--- a/.grok-plugin/marketplace.json+++ b/.grok-plugin/marketplace.json@@ -10,7 +10,7 @@"name": "anidoodle","source": "./plugins/anidoodle","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with scores composed in code.",- "version": "0.7.1",+ "version": "0.7.2","author": {"name": "Alex Greenshpun","url": "https://linkedin.com/in/alexgreensh"diff --git a/plugins/anidoodle/.claude-plugin/plugin.json b/plugins/anidoodle/.claude-plugin/plugin.jsonindex 4f72dec..a7fc0c1 100644--- a/plugins/anidoodle/.claude-plugin/plugin.json+++ b/plugins/anidoodle/.claude-plugin/plugin.json@@ -2,7 +2,7 @@"name": "anidoodle","displayName": "anidoodle","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with scores composed in code.",- "version": "0.7.1",+ "version": "0.7.2","icon": "./assets/icon.png","author": {"name": "Alex Greenshpun",diff --git a/plugins/anidoodle/.codex-plugin/plugin.json b/plugins/anidoodle/.codex-plugin/plugin.jsonindex 2550d8a..2541ac0 100644--- a/plugins/anidoodle/.codex-plugin/plugin.json+++ b/plugins/anidoodle/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "anidoodle",- "version": "0.7.1",+ "version": "0.7.2","description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 32 styles, with scores composed in code.","skills": "./skills/","interface": {diff --git a/plugins/anidoodle/skills/anidoodle/engine/package.json b/plugins/anidoodle/skills/anidoodle/engine/package.jsonindex 755a629..48c833e 100644--- a/plugins/anidoodle/skills/anidoodle/engine/package.json+++ b/plugins/anidoodle/skills/anidoodle/engine/package.json@@ -1,6 +1,6 @@{"name": "anidoodle-engine",- "version": "0.7.1",+ "version": "0.7.2","private": true,"type": "module","description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/banner.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/banner.tsindex 415de2a..fd0053d 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/banner.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/banner.ts@@ -152,12 +152,14 @@ const fineliner = (g: Gfx, a: P, b: P) => rod(g, a, b, [{ t0: 0.82, t1: 0.95, r0: 7, r1: 2.6, c: "#8d8d90", sh: "#48484b" }, { t0: 0.95, t1: 1, r0: 1, r1: 0.7, c: "#bdbdbd", sh: "#6c6c6c" }]);const brush = (g: Gfx, a: P, b: P, handle: string, hsh: string, tip: string) => rod(g, a, b, [{ t0: 0, t1: 0.62, r0: 3, r1: 6, c: handle, sh: hsh }, { t0: 0.62, t1: 0.8, r0: 6.4, r1: 5.8, c: "#d6d0c4", sh: "#817b72" }, { t0: 0.8, t1: 1, r0: 5.8, r1: 0.4, c: tip, sh: mix(tip, "#000000", 0.5), round: true }]);-export const dipPen = (g: Gfx, tip: P, ang: number, s: Pick<State, "glint" | "glintT">) => {+// `seed` pins the pen's two hairlines for a caller outside drawBanner: without it they take the module's+// running SEED, which only drawBanner resets, so another film's frame would depend on render order+export const dipPen = (g: Gfx, tip: P, ang: number, s: Pick<State, "glint" | "glintT">, seed?: number) => {const back: P = [tip[0] - Math.cos(ang) * 340, tip[1] - Math.sin(ang) * 340];const pt = rod(g, back, tip, [{ t0: 0, t1: 0.66, r0: 3.2, r1: 6, c: "#4a2f26", sh: "#1f1411" }, { t0: 0.66, t1: 0.8, r0: 6.4, r1: 5, c: "#c2a063", sh: "#7a6234" }]);const nib = [pt(0.8, -4.8), pt(0.87, -5), pt(0.95, -2.5), pt(1, 0), pt(0.95, 2.5), pt(0.87, 5), pt(0.8, 4.8)];g.group("plain", () => { const c = g.cur, gr = c.createLinearGradient(...pt(0.82, -4), ...pt(0.82, 4)); gr.addColorStop(0, "#f4f1ea"); gr.addColorStop(0.45, "#a6a098"); gr.addColorStop(1, "#5d5953"); fillShape(g, nib, "#000", 0); c.fillStyle = gr; trace(c, nib); c.fill(); });- g.group("ink", () => { ln(g, [pt(0.9, 0), pt(1, 0)], { w: 0.5, op: 0.8, wob: 0 }); ln(g, nib, { closed: true, w: 0.55, op: 0.5, wob: 0.1 }); });+ g.group("ink", () => { ln(g, [pt(0.9, 0), pt(1, 0)], { w: 0.5, op: 0.8, wob: 0, seed: seed ?? SEED++ }); ln(g, nib, { closed: true, w: 0.55, op: 0.5, wob: 0.1, seed: seed === undefined ? SEED++ : seed + 1 }); });// the breather hole and the wet tines. The box is min/max padded: the pen points either way, and a// blot drawn outside its marked box is never composited or cleared (it lingers in the layer pool).g.group("plain", () => { const c = g.cur, v = pt(0.895, 0), w = pt(0.975, 0); g.touch(Math.min(v[0], w[0]) - 6, Math.min(v[1], w[1]) - 6, Math.max(v[0], w[0]) + 6, Math.max(v[1], w[1]) + 6); c.fillStyle = "#34302a"; c.beginPath(); c.arc(v[0], v[1], 1.5, 0, Math.PI * 2); c.fill(); c.fillStyle = IRON; c.globalAlpha = 0.85; c.beginPath(); c.ellipse(w[0], w[1], 3.4, 1.7, ang, 0, Math.PI * 2); c.fill(); c.globalAlpha = 1; });diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/guards.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/guards.tsindex 41d9474..ddd6d73 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/guards.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/guards.ts@@ -63,7 +63,10 @@ export const cadenceTimes = (r: Rendered) => {/** Reverb-to-dry per bar (dB). Pass: every sounding bar >= 10 dB under. */export const reverbCheck = (r: Rendered, sr: number) => {const bpb = beatsPerBar(r.piece.plan.meter), total = r.piece.plan.sections.reduce((a, s) => a + s.bars * bpb, 0), bars: number[] = [];+ // a bar inside a declared breath (authored silence) holds only the ring-out of the phrase before it: not judged, as in the ghost guard+ const rest = (b: number) => (r.piece.arrangement ?? []).some((x) => x.kind === "breath" && b >= x.from * bpb && b < (x.from + x.bars) * bpb);for (let b = 0; b < total; b += bpb) {+ if (rest(b)) continue;const a = Math.round(r.perf.sec(b) * sr), e = Math.min(r.L.length, Math.round(r.perf.sec(b + bpb) * sr)); let ew = 0, ed = 0;for (let c = 0; c < 2; c++) for (let i = a; i < e; i++) { ew += r.wet[c][i] ** 2; ed += r.dry[c][i] ** 2; }if (ed > 1e-9) bars.push(10 * Math.log10((ew + 1e-12) / ed));@@ -113,9 +116,15 @@ export const maskingCheck = (piece: Piece, sr: number, o: { seconds?: number; te};/** Everything at once for a rendered piece. */+/** The documented exemption, in seconds: each declared breath section (authored silence), padded 1 ms so a+ * ghost window whose edge IS the breath edge still counts as inside it. guardReport passes these to ghostCheck. */+export const breathSpans = (r: Pick<Rendered, "piece" | "perf">, bpb: number): [number, number][] =>+ (r.piece.arrangement ?? []).filter((x) => x.kind === "breath").map((x) => [r.perf.sec(x.from * bpb) - 1e-3, r.perf.sec((x.from + x.bars) * bpb) + 1e-3]);+export const guardReport = (r: Rendered, sr: number, seconds: number, o: { masking?: boolean; cache?: VoiceCache; /** each role's band energy, rendered elsewhere (a worker pool) from maskingPlan */ bands?: Partial<Record<Role, number[]>> } = {}) => {const bpb = beatsPerBar(r.piece.plan.meter);- const ghost = ghostCheck([r.L, r.R], sr, { bpm: r.tempo, beatsPerBar: bpb, wet: r.wet, dry: r.dry, cadences: cadenceTimes(r) });+ const breaths = breathSpans(r, bpb);+ const ghost = ghostCheck([r.L, r.R], sr, { bpm: r.tempo, beatsPerBar: bpb, wet: r.wet, dry: r.dry, cadences: cadenceTimes(r), breaths });return { ghost: { pass: ghost.pass, failures: ghost.failures, windows: ghost.windows.length, minOnsetsPerBeat: Math.min(...ghost.windows.map((w) => w.onsetsPerBeat)), maxSustainedShare: Math.max(...ghost.windows.map((w) => w.sustainedShare)) }, reverb: reverbCheck(r, sr), masking: o.masking === false ? null : o.bands ? maskingFromBands(maskingPlan(r.piece, { seconds, tempo: r.tempo, perf: r.perf })!, o.bands) : maskingCheck(r.piece, sr, { seconds, tempo: r.tempo, perf: r.perf, cache: o.cache }), lufs: loudness([r.L, r.R], sr).integrated };};diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.tsindex cbca657..90a2d6f 100644--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts+++ b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts@@ -84,11 +84,13 @@ const timpaniLegacy = (keys: Played[], sr: number, n: number, o: Opts, r: Rng):/** Lead synth: monophonic saw + square, portamento `glide` s between touching notes, a filter envelope re-struck each note, vibrato blooming on long notes (spec 06 lead). */export const leadSynth = (keys: Played[], sr: number, n: number, o: Opts): Out => {const out = out0(n), glide = num(o, "glide", 0.03), cut = num(o, "cut", 1700), envAmt = num(o, "env", 4500), sq = num(o, "square", 0.4), [gl, gr] = pan(num(o, "pan", 0));+ // vibrato depth (fraction of pitch), rate (Hz) and onset (s): defaults are the original voice, bit for bit; a theremin wants ~0.02 at 6 Hz from 0.08 s+ const vDepth = num(o, "vibrato", 0.006), vHz = num(o, "vibHz", 5.5), vAt = num(o, "vibAt", 0.3), vRise = num(o, "vibRise", 0.4);const ks = keys.slice().sort((a, b) => a.t - b.t); let prevF = 0, prevOff = -1, ph = 0, ph2 = 0; const lp = new SVF(sr, cut, 1.2);ks.forEach((k, idx) => {const f = f0(k.p), i0 = Math.round(k.t * sr), nextT = idx + 1 < ks.length ? ks[idx + 1].t : Infinity, dur = Math.min(k.off, nextT) - k.t, tail = nextT < k.off + 0.12 ? nextT - k.t : dur + 0.12;const len = Math.min(n - i0, Math.ceil(Math.max(0.01, tail) * sr)), from = prevF && k.t - prevOff < 0.05 ? prevF : f;- for (let i = 0; i < len; i++) { const t = i / sr, fr = from + (f - from) * Math.min(1, t / Math.max(1e-4, glide)), vib = t > 0.3 ? 1 + 0.006 * Math.sin(TAU * 5.5 * t) * Math.min(1, (t - 0.3) / 0.4) : 1, inc = (fr * vib) / sr;+ for (let i = 0; i < len; i++) { const t = i / sr, fr = from + (f - from) * Math.min(1, t / Math.max(1e-4, glide)), vib = t > vAt ? 1 + vDepth * Math.sin(TAU * vHz * t) * Math.min(1, (t - vAt) / vRise) : 1, inc = (fr * vib) / sr;ph += inc; if (ph >= 1) ph -= 1; ph2 += inc; if (ph2 >= 1) ph2 -= 1;const e = Math.min(1, t / 0.006) * (t < dur ? 1 : Math.exp(-(t - dur) / 0.03));if ((i & 15) === 0) lp.set(clamp(cut + envAmt * k.v * Math.exp(-t / 0.18), 150, 14000), 1.2);diff --git a/plugins/anidoodle/skills/anidoodle/engine/test/guards.test.ts b/plugins/anidoodle/skills/anidoodle/engine/test/guards.test.tsnew file mode 100644index 0000000..efc54d5--- /dev/null+++ b/plugins/anidoodle/skills/anidoodle/engine/test/guards.test.ts@@ -0,0 +1,20 @@+// GUARD TESTS. A declared breath section is authored silence: the ghost guard must not judge it, and+// guardReport must actually hand those spans to ghostCheck (it once did not, so every score with a+// breath failed on its own silence).+// node tools/test.mjs guards+import { breathSpans, ghostCheck } from "../src/canvas-core/music/guards";+import type { Rendered } from "../src/canvas-core/music/render";++export const name = "guards";+export const run = (ok: (cond: boolean, label: string) => void) => {+ const SR = 8000, bpm = 120, spb = 0.5;+ // 1. breathSpans reads breath sections only, in seconds at the piece's tempo+ const r = { piece: { arrangement: [{ kind: "groove", from: 0, bars: 2 }, { kind: "breath", from: 2, bars: 2 }, { kind: "drop", from: 4, bars: 1 }] }, perf: { sec: (beat: number) => beat * spb } } as unknown as Pick<Rendered, "piece" | "perf">;+ const sp = breathSpans(r, 4);+ ok(sp.length === 1 && Math.abs(sp[0][0] - 3.999) < 1e-9 && Math.abs(sp[0][1] - 8.001) < 1e-9, `one breath, bars 2-4 = 4 s to 8 s, padded 1 ms (${JSON.stringify(sp)})`);+ // 2. a held, onset-free pad is formless; inside a declared breath it is not judged+ const n = SR * 8, x = new Float32Array(n); for (let i = 0; i < n; i++) x[i] = 0.2 * Math.sin((2 * Math.PI * 220 * i) / SR);+ const bare = ghostCheck([x, x], SR, { bpm, beatsPerBar: 4 }), exempt = ghostCheck([x, x], SR, { bpm, beatsPerBar: 4, breaths: [[-0.001, 8.001]] });+ ok(!bare.pass, `a held pad with no onsets fails the ghost guard (${bare.failures} windows)`);+ ok(exempt.pass, "the same pad inside a declared breath passes");+};diff --git a/skills/anidoodle/engine/package-lock.json b/skills/anidoodle/engine/package-lock.jsonindex 68a3210..f7051d0 100644--- a/skills/anidoodle/engine/package-lock.json+++ b/skills/anidoodle/engine/package-lock.json@@ -1,12 +1,12 @@{"name": "anidoodle-engine",- "version": "0.7.1",+ "version": "0.7.2","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "anidoodle-engine",- "version": "0.7.1",+ "version": "0.7.2","dependencies": {"esbuild": "0.25.12"},diff --git a/skills/anidoodle/engine/package.json b/skills/anidoodle/engine/package.jsonindex 755a629..48c833e 100644--- a/skills/anidoodle/engine/package.json+++ b/skills/anidoodle/engine/package.json@@ -1,6 +1,6 @@{"name": "anidoodle-engine",- "version": "0.7.1",+ "version": "0.7.2","private": true,"type": "module","description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",diff --git a/skills/anidoodle/engine/src/canvas-core/banner.ts b/skills/anidoodle/engine/src/canvas-core/banner.tsindex 415de2a..fd0053d 100644--- a/skills/anidoodle/engine/src/canvas-core/banner.ts+++ b/skills/anidoodle/engine/src/canvas-core/banner.ts@@ -152,12 +152,14 @@ const fineliner = (g: Gfx, a: P, b: P) => rod(g, a, b, [{ t0: 0.82, t1: 0.95, r0: 7, r1: 2.6, c: "#8d8d90", sh: "#48484b" }, { t0: 0.95, t1: 1, r0: 1, r1: 0.7, c: "#bdbdbd", sh: "#6c6c6c" }]);const brush = (g: Gfx, a: P, b: P, handle: string, hsh: string, tip: string) => rod(g, a, b, [{ t0: 0, t1: 0.62, r0: 3, r1: 6, c: handle, sh: hsh }, { t0: 0.62, t1: 0.8, r0: 6.4, r1: 5.8, c: "#d6d0c4", sh: "#817b72" }, { t0: 0.8, t1: 1, r0: 5.8, r1: 0.4, c: tip, sh: mix(tip, "#000000", 0.5), round: true }]);-export const dipPen = (g: Gfx, tip: P, ang: number, s: Pick<State, "glint" | "glintT">) => {+// `seed` pins the pen's two hairlines for a caller outside drawBanner: without it they take the module's+// running SEED, which only drawBanner resets, so another film's frame would depend on render order+export const dipPen = (g: Gfx, tip: P, ang: number, s: Pick<State, "glint" | "glintT">, seed?: number) => {const back: P = [tip[0] - Math.cos(ang) * 340, tip[1] - Math.sin(ang) * 340];const pt = rod(g, back, tip, [{ t0: 0, t1: 0.66, r0: 3.2, r1: 6, c: "#4a2f26", sh: "#1f1411" }, { t0: 0.66, t1: 0.8, r0: 6.4, r1: 5, c: "#c2a063", sh: "#7a6234" }]);const nib = [pt(0.8, -4.8), pt(0.87, -5), pt(0.95, -2.5), pt(1, 0), pt(0.95, 2.5), pt(0.87, 5), pt(0.8, 4.8)];g.group("plain", () => { const c = g.cur, gr = c.createLinearGradient(...pt(0.82, -4), ...pt(0.82, 4)); gr.addColorStop(0, "#f4f1ea"); gr.addColorStop(0.45, "#a6a098"); gr.addColorStop(1, "#5d5953"); fillShape(g, nib, "#000", 0); c.fillStyle = gr; trace(c, nib); c.fill(); });- g.group("ink", () => { ln(g, [pt(0.9, 0), pt(1, 0)], { w: 0.5, op: 0.8, wob: 0 }); ln(g, nib, { closed: true, w: 0.55, op: 0.5, wob: 0.1 }); });+ g.group("ink", () => { ln(g, [pt(0.9, 0), pt(1, 0)], { w: 0.5, op: 0.8, wob: 0, seed: seed ?? SEED++ }); ln(g, nib, { closed: true, w: 0.55, op: 0.5, wob: 0.1, seed: seed === undefined ? SEED++ : seed + 1 }); });// the breather hole and the wet tines. The box is min/max padded: the pen points either way, and a// blot drawn outside its marked box is never composited or cleared (it lingers in the layer pool).g.group("plain", () => { const c = g.cur, v = pt(0.895, 0), w = pt(0.975, 0); g.touch(Math.min(v[0], w[0]) - 6, Math.min(v[1], w[1]) - 6, Math.max(v[0], w[0]) + 6, Math.max(v[1], w[1]) + 6); c.fillStyle = "#34302a"; c.beginPath(); c.arc(v[0], v[1], 1.5, 0, Math.PI * 2); c.fill(); c.fillStyle = IRON; c.globalAlpha = 0.85; c.beginPath(); c.ellipse(w[0], w[1], 3.4, 1.7, ang, 0, Math.PI * 2); c.fill(); c.globalAlpha = 1; });diff --git a/skills/anidoodle/engine/src/canvas-core/music/guards.ts b/skills/anidoodle/engine/src/canvas-core/music/guards.tsindex 41d9474..ddd6d73 100644--- a/skills/anidoodle/engine/src/canvas-core/music/guards.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/guards.ts@@ -63,7 +63,10 @@ export const cadenceTimes = (r: Rendered) => {/** Reverb-to-dry per bar (dB). Pass: every sounding bar >= 10 dB under. */export const reverbCheck = (r: Rendered, sr: number) => {const bpb = beatsPerBar(r.piece.plan.meter), total = r.piece.plan.sections.reduce((a, s) => a + s.bars * bpb, 0), bars: number[] = [];+ // a bar inside a declared breath (authored silence) holds only the ring-out of the phrase before it: not judged, as in the ghost guard+ const rest = (b: number) => (r.piece.arrangement ?? []).some((x) => x.kind === "breath" && b >= x.from * bpb && b < (x.from + x.bars) * bpb);for (let b = 0; b < total; b += bpb) {+ if (rest(b)) continue;const a = Math.round(r.perf.sec(b) * sr), e = Math.min(r.L.length, Math.round(r.perf.sec(b + bpb) * sr)); let ew = 0, ed = 0;for (let c = 0; c < 2; c++) for (let i = a; i < e; i++) { ew += r.wet[c][i] ** 2; ed += r.dry[c][i] ** 2; }if (ed > 1e-9) bars.push(10 * Math.log10((ew + 1e-12) / ed));@@ -113,9 +116,15 @@ export const maskingCheck = (piece: Piece, sr: number, o: { seconds?: number; te};/** Everything at once for a rendered piece. */+/** The documented exemption, in seconds: each declared breath section (authored silence), padded 1 ms so a+ * ghost window whose edge IS the breath edge still counts as inside it. guardReport passes these to ghostCheck. */+export const breathSpans = (r: Pick<Rendered, "piece" | "perf">, bpb: number): [number, number][] =>+ (r.piece.arrangement ?? []).filter((x) => x.kind === "breath").map((x) => [r.perf.sec(x.from * bpb) - 1e-3, r.perf.sec((x.from + x.bars) * bpb) + 1e-3]);+export const guardReport = (r: Rendered, sr: number, seconds: number, o: { masking?: boolean; cache?: VoiceCache; /** each role's band energy, rendered elsewhere (a worker pool) from maskingPlan */ bands?: Partial<Record<Role, number[]>> } = {}) => {const bpb = beatsPerBar(r.piece.plan.meter);- const ghost = ghostCheck([r.L, r.R], sr, { bpm: r.tempo, beatsPerBar: bpb, wet: r.wet, dry: r.dry, cadences: cadenceTimes(r) });+ const breaths = breathSpans(r, bpb);+ const ghost = ghostCheck([r.L, r.R], sr, { bpm: r.tempo, beatsPerBar: bpb, wet: r.wet, dry: r.dry, cadences: cadenceTimes(r), breaths });return { ghost: { pass: ghost.pass, failures: ghost.failures, windows: ghost.windows.length, minOnsetsPerBeat: Math.min(...ghost.windows.map((w) => w.onsetsPerBeat)), maxSustainedShare: Math.max(...ghost.windows.map((w) => w.sustainedShare)) }, reverb: reverbCheck(r, sr), masking: o.masking === false ? null : o.bands ? maskingFromBands(maskingPlan(r.piece, { seconds, tempo: r.tempo, perf: r.perf })!, o.bands) : maskingCheck(r.piece, sr, { seconds, tempo: r.tempo, perf: r.perf, cache: o.cache }), lufs: loudness([r.L, r.R], sr).integrated };};diff --git a/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts b/skills/anidoodle/engine/src/canvas-core/music/orchestra.tsindex cbca657..90a2d6f 100644--- a/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts+++ b/skills/anidoodle/engine/src/canvas-core/music/orchestra.ts@@ -84,11 +84,13 @@ const timpaniLegacy = (keys: Played[], sr: number, n: number, o: Opts, r: Rng):/** Lead synth: monophonic saw + square, portamento `glide` s between touching notes, a filter envelope re-struck each note, vibrato blooming on long notes (spec 06 lead). */export const leadSynth = (keys: Played[], sr: number, n: number, o: Opts): Out => {const out = out0(n), glide = num(o, "glide", 0.03), cut = num(o, "cut", 1700), envAmt = num(o, "env", 4500), sq = num(o, "square", 0.4), [gl, gr] = pan(num(o, "pan", 0));+ // vibrato depth (fraction of pitch), rate (Hz) and onset (s): defaults are the original voice, bit for bit; a theremin wants ~0.02 at 6 Hz from 0.08 s+ const vDepth = num(o, "vibrato", 0.006), vHz = num(o, "vibHz", 5.5), vAt = num(o, "vibAt", 0.3), vRise = num(o, "vibRise", 0.4);const ks = keys.slice().sort((a, b) => a.t - b.t); let prevF = 0, prevOff = -1, ph = 0, ph2 = 0; const lp = new SVF(sr, cut, 1.2);ks.forEach((k, idx) => {const f = f0(k.p), i0 = Math.round(k.t * sr), nextT = idx + 1 < ks.length ? ks[idx + 1].t : Infinity, dur = Math.min(k.off, nextT) - k.t, tail = nextT < k.off + 0.12 ? nextT - k.t : dur + 0.12;const len = Math.min(n - i0, Math.ceil(Math.max(0.01, tail) * sr)), from = prevF && k.t - prevOff < 0.05 ? prevF : f;- for (let i = 0; i < len; i++) { const t = i / sr, fr = from + (f - from) * Math.min(1, t / Math.max(1e-4, glide)), vib = t > 0.3 ? 1 + 0.006 * Math.sin(TAU * 5.5 * t) * Math.min(1, (t - 0.3) / 0.4) : 1, inc = (fr * vib) / sr;+ for (let i = 0; i < len; i++) { const t = i / sr, fr = from + (f - from) * Math.min(1, t / Math.max(1e-4, glide)), vib = t > vAt ? 1 + vDepth * Math.sin(TAU * vHz * t) * Math.min(1, (t - vAt) / vRise) : 1, inc = (fr * vib) / sr;ph += inc; if (ph >= 1) ph -= 1; ph2 += inc; if (ph2 >= 1) ph2 -= 1;const e = Math.min(1, t / 0.006) * (t < dur ? 1 : Math.exp(-(t - dur) / 0.03));if ((i & 15) === 0) lp.set(clamp(cut + envAmt * k.v * Math.exp(-t / 0.18), 150, 14000), 1.2);diff --git a/skills/anidoodle/engine/test/guards.test.ts b/skills/anidoodle/engine/test/guards.test.tsnew file mode 100644index 0000000..efc54d5--- /dev/null+++ b/skills/anidoodle/engine/test/guards.test.ts@@ -0,0 +1,20 @@+// GUARD TESTS. A declared breath section is authored silence: the ghost guard must not judge it, and+// guardReport must actually hand those spans to ghostCheck (it once did not, so every score with a+// breath failed on its own silence).+// node tools/test.mjs guards+import { breathSpans, ghostCheck } from "../src/canvas-core/music/guards";+import type { Rendered } from "../src/canvas-core/music/render";++export const name = "guards";+export const run = (ok: (cond: boolean, label: string) => void) => {+ const SR = 8000, bpm = 120, spb = 0.5;+ // 1. breathSpans reads breath sections only, in seconds at the piece's tempo+ const r = { piece: { arrangement: [{ kind: "groove", from: 0, bars: 2 }, { kind: "breath", from: 2, bars: 2 }, { kind: "drop", from: 4, bars: 1 }] }, perf: { sec: (beat: number) => beat * spb } } as unknown as Pick<Rendered, "piece" | "perf">;+ const sp = breathSpans(r, 4);+ ok(sp.length === 1 && Math.abs(sp[0][0] - 3.999) < 1e-9 && Math.abs(sp[0][1] - 8.001) < 1e-9, `one breath, bars 2-4 = 4 s to 8 s, padded 1 ms (${JSON.stringify(sp)})`);+ // 2. a held, onset-free pad is formless; inside a declared breath it is not judged+ const n = SR * 8, x = new Float32Array(n); for (let i = 0; i < n; i++) x[i] = 0.2 * Math.sin((2 * Math.PI * 220 * i) / SR);+ const bare = ghostCheck([x, x], SR, { bpm, beatsPerBar: 4 }), exempt = ghostCheck([x, x], SR, { bpm, beatsPerBar: 4, breaths: [[-0.001, 8.001]] });+ ok(!bare.pass, `a held pad with no onsets fails the ghost guard (${bare.failures} windows)`);+ ok(exempt.pass, "the same pad inside a declared breath passes");+};