Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

review fixes: the incoming shot owns the cut frame; bounds and input checks on seams, the arc and the deck; the timpani pin is the timpani's alone

Alex Greenshpun6ea89919097c
diff --git a/.gitignore b/.gitignore
index 2ada8c5..b283bf6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
# build + render output
skills/anidoodle/engine/node_modules/
+skills/anidoodle/engine/node_modules
skills/anidoodle/engine/out/
skills/anidoodle/engine/dist/
skills/anidoodle/engine/.tmp/
diff --git a/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts b/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts
index 203d050..0db1098 100644
--- a/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts
+++ b/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts
@@ -31,16 +31,6 @@ export type Pose = {
const SPINE_UP = [14, 38, 40, 44, 54, 66, 66, 50, 38, 34], SPINE_DN = [22, 52, 44, 42, 68, 90, 76, 48, 36, 32];
const TAIL_W = [15, 13, 12, 12, 13, 11], FORE_W = [20, 30, 19, 12, 8], HIND_W = [44, 30, 13, 12, 8];
-// the extended flight phase: every foot off the ground, the spine opened out, the forelegs reaching
-export const EXTENDED: Pose = {
- spine: [[322, 500], [365, 505], [440, 512], [505, 516], [570, 522], [640, 524], [700, 518], [752, 503], [800, 492], [838, 486]],
- tail: [[326, 486], [262, 474], [196, 476], [132, 458], [84, 424], [56, 392]],
- foreN: [[690, 494], [708, 545], [798, 584], [898, 610], [956, 626]],
- foreF: [[698, 498], [716, 548], [812, 566], [916, 574], [974, 582]],
- hindN: [[372, 520], [292, 584], [188, 572], [112, 594], [80, 606]],
- hindF: [[380, 522], [310, 604], [212, 612], [140, 642], [110, 656]],
- head: 0.1,
-};
// a tuft: a tapered leaf from radius r0 to r1 along angle a, darker at its root (the mark cheetahDusk is made of)
const tuft = (c: Ctx, o: P, a: number, r0: number, r1: number, w: number, col: string, vein = 0.22, root = 0.6) => {
diff --git a/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts b/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts
index 7ce27d5..441971c 100644
--- a/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts
+++ b/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts
@@ -64,7 +64,6 @@ const held = (F: number): Rig => { // every pose she holds, and the m
if (F < CUE.hold) { const d = Math.sin(ramp(F, CUE.bow, CUE.hold) * Math.PI), q = Math.sin(F * 1.9) * d; return { ...S.bow.rig, lumb: S.bow.rig.lumb - 7 * d, headH: S.bow.rig.headH + 14 * d, head: S.bow.rig.head - 6 * d, tail: S.bow.rig.tail.map((a, i) => a + q * i * 1.6 + d * i * 3) }; }
if (F < CUE.up) return mixRig(S.bow.rig, S.stand.rig, back(ramp(F, CUE.hold, CUE.up)));
if (F < CUE.go) return mixRig(S.stand.rig, S.crouch.rig, inOut(ramp(F, CUE.up, CUE.go)));
- if (F < CUE.slid) { const d = Math.sin(ramp(F, CUE.brake + 6, CUE.slid + 10) * Math.PI); return { ...S.skid.rig, lumb: S.skid.rig.lumb + 9 * d, headH: S.skid.rig.headH - 20 * d, head: S.skid.rig.head + 5 * d, tail: S.skid.rig.tail.map((a, i) => a + d * i * 5 + Math.sin(F * 0.9) * i * 1.5 * d) }; }
return mixRig(S.skid.rig, S.stand.rig, back(ramp(F, CUE.slid, CUE.stood)));
};
const standing = (F: number) => { const s = settle(idle(held(F), F)), q = fk(s.rig, 0, s.y, 0); return { rig: s.rig, y: s.y, x: HIND_X - q.hindN[4][0] }; };
diff --git a/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts b/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts
index fbbd228..85928ea 100644
--- a/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts
+++ b/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts
@@ -63,7 +63,7 @@ export const drawFar = (c: Ctx, w: Country, X: number, F: number, horizon: numbe
for (const t of w.trees) { const x = 540 + (t.g - X) * 0.22; if (x < -260 || x > 1340) continue; if (t.kind === "dead") deadTree(c, x, horizon, t.h, t.seed, tree); else acacia(c, x, horizon, t.h, t.seed, tree, treeLit); }
for (const m of w.mid) { const x = 540 + (m.g - X) * 0.5; if (x < -200 || x > 1280) continue; if (m.kind === "mound") mound(c, x, horizon, m.h, mix(RUST, NIGHT, 0.72)); else if (m.kind === "kopje") kopje(c, x, horizon, m.h, m.seed, near, mix(RUST, NIGHT, 0.6)); else if (m.kind === "reeds") reeds(c, x, horizon, m.h, m.seed, nearLit, F, lean); else bush(c, x, horizon, m.h, m.seed, near, nearLit); }
};
-/** The pan: shallow water lying on the ground she runs over, with the sun laid down in it. Returns how much of it is under her (0-1). */
+/** The pan: shallow water lying on the ground she runs over, with the sun laid down in it. */
export const drawPan = (c: Ctx, w: Country, X: number, F: number, horizon: number, v: number) => {
const a = 540 + (w.pan[0] - X), b = 540 + (w.pan[1] - X); if (b < -40 || a > 1120) return;
const x0 = Math.max(-20, a), x1 = Math.min(1100, b), y0 = horizon + 8, y1 = horizon + 86;
@@ -106,4 +106,3 @@ export const drawBurst = (c: Ctx, b: Burst) => {
else leaf(c, b.x - d * 70 * k * b.big, b.y - 4 - d * 56 * k * b.big, a, (24 + d * 58) * b.big * Math.min(1, k * 3), (7 + q() * 8) * b.big, mix(mix(OCHRE, PALE, 0.4), NIGHT, 0.12 + q() * 0.25), (0.62 - d * 0.15) * (1 - k));
}
};
-export const at = (p: P, dx: number, dy: number): P => [p[0] + dx, p[1] + dy];
diff --git a/skills/anidoodle/engine/src/canvas-core/music/arc.ts b/skills/anidoodle/engine/src/canvas-core/music/arc.ts
index 9f38b0c..c503bb6 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/arc.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/arc.ts
@@ -16,6 +16,7 @@ export type ArcReport = {
introUnderBody: number; // how far the first 2.5 s sit under the median (positive = quieter)
endUnderPeak: number; // how far the last second sits under the loudest moment
seamJump: number; // loops: the level step from the last second to the first
+ insideJump: number; // loops: the largest step between two neighbouring seconds anywhere else in the piece
lra: number;
findings: ArcFinding[];
};
@@ -24,26 +25,31 @@ const SILENT = -70;
/** How the sound moves over the piece. `payoffS` is the second the picture pays off, when the film has one. */
export const arcReport = (chans: Float32Array[], sr: number, o: { loop?: boolean; payoffS?: number } = {}): ArcReport => {
+ if (!chans.length || !chans[0]) throw new Error("arcReport needs at least one channel of sound");
const l = loudness(chans, sr), m = l.momentary, hop = l.hopS, dur = chans[0].length / sr, loop = !!o.loop, at = (i: number) => i * hop + 0.2;
const live = m.filter((x) => x > SILENT).sort((a, b) => a - b), medianLu = live.length ? live[Math.floor(live.length / 2)] : SILENT;
let pi = 0; m.forEach((x, i) => { if (x > m[pi]) pi = i; });
const peakLu = m.length ? m[pi] : SILENT, peakS = at(pi), peakAt = dur > 0 ? peakS / dur : 0, win = (a: number, b: number) => { const w = m.filter((_, i) => at(i) >= a && at(i) <= b); return w.length ? mean(w) : SILENT; };
const introUnderBody = medianLu - win(0, 2.5), endUnderPeak = peakLu - win(dur - 1, dur), seamJump = m.length ? Math.abs(win(dur - 1, dur) - win(0, 1)) : 0;
+ // a loop's join is heard when it is a bigger step than the piece makes anywhere else: a phrase ending into a quiet bar is the music, not a seam
+ let insideJump = 0; for (let t = 0; t + 2 <= dur; t++) insideJump = Math.max(insideJump, Math.abs(win(t + 1, t + 2) - win(t, t + 1)));
+ const lra = Number.isFinite(l.lra) ? l.lra : 0, silent = peakLu <= SILENT;
const f: ArcFinding[] = [], r1 = (x: number) => x.toFixed(1), pc = (x: number) => `${Math.round(x * 100)}%`;
+ if (silent) return { durationS: dur, loop, medianLu, peakLu, peakS, peakAt, peakOverMedian: 0, introUnderBody: 0, endUnderPeak: 0, seamJump: 0, insideJump: 0, lra, findings: f }; // nothing sounds: nothing to shape
if (dur >= 8 && peakLu - medianLu < 2) f.push({ level: "warn", msg: `nothing is the high point: the loudest moment is only ${r1(peakLu - medianLu)} LU over the usual level`, fix: "hold something back (the low drum, the top octave, a doubling) until the payoff, and thin the bars before it" });
- if (dur >= 20 && l.lra < 5) f.push({ level: "warn", msg: `little contrast: the loudness range is ${r1(l.lra)} LU over ${r1(dur)} s`, fix: "a piece this long wants 5 to 8: give one section fewer parts, or a bar of near silence before the high point" });
+ if (dur >= 20 && lra < 5) f.push({ level: "warn", msg: `little contrast: the loudness range is ${r1(lra)} LU over ${r1(dur)} s`, fix: "a piece this long wants 5 to 8: give one section fewer parts, or a bar of near silence before the high point" });
if (o.payoffS !== undefined && Math.abs(peakS - o.payoffS) > 1.5) f.push({ level: "warn", msg: `the loudest moment is at ${r1(peakS)} s, the picture pays off at ${r1(o.payoffS)} s`, fix: "move the fullest bar onto the payoff, or thin whatever is out-shouting it" });
- if (loop) { if (seamJump > 3) f.push({ level: "warn", msg: `the level steps ${r1(seamJump)} LU where the loop comes round`, fix: "end as thin as it begins, or begin as full as it ends" }); }
+ if (loop) { if (seamJump > 3 && seamJump > insideJump) f.push({ level: "warn", msg: `the level steps ${r1(seamJump)} LU where the loop comes round, more than anywhere inside it (${r1(insideJump)} LU)`, fix: "end as thin as it begins, or begin as full as it ends" }); }
else {
if (dur >= 8 && introUnderBody < 0) f.push({ level: "info", msg: `it opens ${r1(-introUnderBody)} LU over its usual level: there is nothing left to build to`, fix: "open with fewer parts and no low drum, 5 to 12 LU under the body, for the first two or three seconds" });
if (dur >= 8 && introUnderBody > 12) f.push({ level: "info", msg: `the first 2.5 s sit ${r1(introUnderBody)} LU under the rest: it reads as nothing happening yet`, fix: "frame 0 wants one sound with a reason (a drone, the first chord), even a soft one" });
if (dur >= 8 && peakAt > 0.8) f.push({ level: "warn", msg: `the loudest moment is ${pc(peakAt)} of the way through: the ending out-shouts the film`, fix: "an ending resolves, it does not climb: stop on a bar line, leave a breath, then one soft element" });
else if (dur >= 8 && endUnderPeak < 8) f.push({ level: "info", msg: `the last second is only ${r1(endUnderPeak)} LU under the loudest moment`, fix: "let the ending take parts away: the close sits 8 to 20 dB under the peak" });
}
- return { durationS: dur, loop, medianLu, peakLu, peakS, peakAt, peakOverMedian: peakLu - medianLu, introUnderBody, endUnderPeak, seamJump, lra: l.lra, findings: f };
+ return { durationS: dur, loop, medianLu, peakLu, peakS, peakAt, peakOverMedian: peakLu - medianLu, introUnderBody, endUnderPeak, seamJump, insideJump, lra, findings: f };
};
export const arcText = (a: ArcReport) => {
- const r1 = (x: number) => x.toFixed(1), head = `ARC usual ${r1(a.medianLu)} LUFS · loudest ${r1(a.peakLu)} at ${r1(a.peakS)} s (${Math.round(a.peakAt * 100)}% through, ${r1(a.peakOverMedian)} LU over) · range ${r1(a.lra)} LU · ${a.loop ? `loop seam step ${r1(a.seamJump)} LU` : `opens ${r1(a.introUnderBody)} LU under, ends ${r1(a.endUnderPeak)} LU under the peak`}`;
+ const r1 = (x: number) => x.toFixed(1), head = `ARC usual ${r1(a.medianLu)} LUFS · loudest ${r1(a.peakLu)} at ${r1(a.peakS)} s (${Math.round(a.peakAt * 100)}% through, ${r1(a.peakOverMedian)} LU over) · range ${r1(a.lra)} LU · ${a.loop ? `loop seam step ${r1(a.seamJump)} LU (largest inside ${r1(a.insideJump)})` : `opens ${r1(a.introUnderBody)} LU under, ends ${r1(a.endUnderPeak)} LU under the peak`}`;
return [head, ...(a.findings.length ? a.findings.map((f) => ` ${f.level.toUpperCase().padEnd(4)} ${f.msg}\n -> ${f.fix}`) : [" the shape holds: nothing to answer"])].join("\n");
};
diff --git a/skills/anidoodle/engine/src/canvas-core/music/render.ts b/skills/anidoodle/engine/src/canvas-core/music/render.ts
index e9430ac..486f3de 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/render.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/render.ts
@@ -65,8 +65,8 @@ const v2Job = (piece: Piece, pt: Part, pi: number, keys: Played[], perf: Perform
const transient = style.master === "gentle" && tg && isStruck(pt.inst, pt.opts) ? tg : undefined;
const post: StemPost | undefined = lofi || amp !== undefined || transient ? { id: pt.id, seed: piece.seed, ...(lofi ? { lofi, period } : {}), ...(amp !== undefined ? { amp } : {}), ...(transient ? { transient } : {}) } : undefined;
const bank = pt.opts?.sampled === false ? undefined : bankFor(pt.inst, typeof pt.opts?.variant === "string" ? pt.opts.variant : undefined);
- // a recorded drum pinned to a note plays it, as the modelled one does: a drum lane's written pitch is a placeholder
- const pin = bank && typeof pt.opts?.pitch === "number" ? pinnedPitch(pt.opts.pitch as number, bank.entry.range) : undefined, played = pin === undefined ? keys : keys.map((k) => ({ ...k, p: pin }));
+ // a recorded timpani pinned to a note plays it, as the modelled one does: a drum lane's written pitch is a placeholder
+ const pin = bank && pt.inst === "timpani" && typeof pt.opts?.pitch === "number" ? pinnedPitch(pt.opts.pitch as number, bank.entry.range) : undefined, played = pin === undefined ? keys : keys.map((k) => ({ ...k, p: pin }));
const base = bank ? { kind: "sampled" as const, bank: bank.id, bankHash: bank.hash, inst: pt.inst, keys: played, pedal: perf.pedal, sr, n, seed: pt.inst === "piano" ? piece.seed + pi : piece.seed * 101 + pi, opts: pt.opts }
: pt.inst === "piano" ? (o.piano ? { kind: "piano" as const, keys, pedal: perf.pedal, sr, n, seed: piece.seed + pi, v1: o.piano } : { kind: "piano" as const, keys, pedal: perf.pedal, sr, n, seed: piece.seed + pi, opts: pt.opts ?? {} })
: { kind: "voice" as const, inst: pt.inst, opts: pt.opts, keys, sr, n, seed: piece.seed * 101 + pi, ctx };
diff --git a/skills/anidoodle/engine/src/canvas-core/music/sampler.ts b/skills/anidoodle/engine/src/canvas-core/music/sampler.ts
index 49129a2..6c909f0 100644
--- a/skills/anidoodle/engine/src/canvas-core/music/sampler.ts
+++ b/skills/anidoodle/engine/src/canvas-core/music/sampler.ts
@@ -62,7 +62,7 @@ export const sampleCutoff = (e: SampleEntry, z: SampleZone, k: Played, sr: numbe
};
export const sampleGain = (e: SampleEntry, z: SampleZone, v: number) => e.normalized ? pianoVelocity(v) * db(-8 * Math.max(0, 0.6 - v)) : v <= 0 ? 0 : db(clamp(16 * (v - layerV(e, z.layer)), -6, 6));
/** A drum tuned to one note (a timpani in a drum lane) plays that note whatever the lane wrote, moved by octaves into what was recorded. */
-export const pinnedPitch = (pitch: number, range: readonly [number, number] | readonly number[]) => { let p = Math.round(pitch); while (p < range[0]) p += 12; while (p > range[1]) p -= 12; return p < range[0] ? range[0] : p; };
+export const pinnedPitch = (pitch: number, range: readonly [number, number] | readonly number[]) => { if (!Number.isFinite(pitch)) throw new Error(`a pinned pitch must be a note number, got ${pitch}`); let p = Math.round(pitch); while (p < range[0]) p += 12; while (p > range[1]) p -= 12; return p < range[0] ? range[0] : p; };
/** Nearest pitch, then nearest layer, then this note's seeded recording. State stays local to a render. */
export const sampleZones = (bank: SampleBank, keys: Played[], seed: number, pedal: PedalSpan[] = [], art?: "rel") => {
const previous = new Map<string, SampleBank["zones"][number]>(), e = bank.entry, pool = bank.zones.filter(({ zone }) => zone.art === art);
diff --git a/skills/anidoodle/engine/src/canvas-core/seams.ts b/skills/anidoodle/engine/src/canvas-core/seams.ts
index 93e904c..cf061c5 100644
--- a/skills/anidoodle/engine/src/canvas-core/seams.ts
+++ b/skills/anidoodle/engine/src/canvas-core/seams.ts
@@ -6,13 +6,16 @@
// Which seam a story is asking for, and when none of these is, is references/motion-grammar.md.
//
// const m = matchedMove({ dir: 0, exitDist: 260, exitF: 12, entryF: 40 });
-// sceneA camera look = restA + m.out(local, CUT) accelerates away over the 12 frames before CUT
-// sceneB camera look = restB + m.in(local, CUT) arrives over the 40 frames after, at rest on restB
+// sceneA camera look = restA + m.out(local, CUT) accelerates away over its last 12 frames, the last being CUT - 1
+// sceneB camera look = restB + m.in(local, CUT) arrives over the 40 frames from CUT, at rest on restB
// const z = matchedZoom({ push: 1.2, exitF: 6, entryF: 15 });
// sceneA zoom = zoomA * z.out(local, CUT); sceneB zoom = zoomB * z.in(local, CUT); a flight through the cut
-// checkSeam(velocityAt(lookA, CUT), velocityAt(lookB, CUT + 1), { W, fps }) findings, empty when it holds
+// checkSeam(velocityAt(lookA, CUT - 1), velocityAt(lookB, CUT + 1), { W, fps }) findings, empty when it holds
// checkSeamPlan([{ type: "iris" }, { type: "matched cut" }, ...]) a seam used a third time
//
+// The incoming shot owns the cut frame, as everywhere in the engine: the outgoing shot's last
+// frame on screen is CUT - 1, and that frame is its fastest. The step a viewer sees into CUT - 1 and
+// the step they see out of CUT are the same size.
// Everything is a pure function of its arguments. Distances are in the units of the thing they
// are added to (world units for a camera's look), speeds in those units per frame.
import type { P } from "./core";
@@ -32,26 +35,29 @@ export const entryDistance = (speed: number, frames: number, ease: Ease = easeOu
export type MatchedMove = {
speed: number; // per frame, on both sides of the cut
entryDist: number; // how far out the incoming shot starts
- /** What to add to the outgoing camera's look: 0 until the exit begins, `exitDist` along `dir` at the cut. */
+ /** What to add to the outgoing camera's look: 0 until the exit begins, `exitDist` along `dir` on its last frame, `cut - 1`. */
out: (local: number, cut: number) => P;
/** What to add to the incoming camera's look: `entryDist` short of rest at the cut, 0 from `entryF` frames after it. */
in: (local: number, cut: number) => P;
};
/** A cut hidden in travel. `dir` is the direction of travel in radians (0 is +x); the two sides share it and the speed. */
export const matchedMove = (o: { dir?: number; exitDist: number; exitF: number; entryF: number }): MatchedMove => {
- if (!(o.exitF >= 2) || !(o.entryF >= 2)) throw new Error(`matchedMove: an exit and an entry need at least 2 frames each (got ${o.exitF} and ${o.entryF})`);
+ if (!(o.exitF >= 2) || !(o.entryF >= 2) || !Number.isFinite(o.exitF) || !Number.isFinite(o.entryF)) throw new Error(`matchedMove: an exit and an entry need at least 2 frames each (got ${o.exitF} and ${o.entryF})`);
+ if (!Number.isFinite(o.exitDist) || !Number.isFinite(o.dir ?? 0)) throw new Error(`matchedMove: exitDist and dir must be numbers (got ${o.exitDist} and ${o.dir})`);
const ux = Math.cos(o.dir ?? 0), uy = Math.sin(o.dir ?? 0), speed = exitSpeed(o.exitDist, o.exitF), entryDist = entryDistance(speed, o.entryF);
return {
speed, entryDist,
- out: (local, cut) => { const d = o.exitDist * easeIn(ramp(local, cut - o.exitF, cut)); return [ux * d, uy * d]; },
+ out: (local, cut) => { const d = o.exitDist * easeIn(ramp(local, cut - 1 - o.exitF, cut - 1)); return [ux * d, uy * d]; },
in: (local, cut) => { const d = -entryDist * (1 - easeOut(ramp(local, cut, cut + o.entryF))); return [ux * d, uy * d]; },
};
};
+/** The smallest an incoming shot may open at, as a share of its resting size. */
+export const MIN_ZOOM_FROM = 0.4;
export type MatchedZoom = {
rate: number; // change of log(zoom) per frame, on both sides of the cut
from: number; // the scale the incoming shot opens at, relative to its rest
- /** Multiply the outgoing camera's zoom by this: 1 until the exit begins, `push` at the cut. */
+ /** Multiply the outgoing camera's zoom by this: 1 until the exit begins, `push` on its last frame, `cut - 1`. */
out: (local: number, cut: number) => number;
/** Multiply the incoming camera's zoom by this: `from` at the cut, 1 from `entryF` frames after it. */
in: (local: number, cut: number) => number;
@@ -60,11 +66,13 @@ export type MatchedZoom = {
export const matchedZoom = (o: { push?: number; exitF: number; entryF: number }): MatchedZoom => {
const push = o.push ?? 1.2;
if (!(push > 1)) throw new Error(`matchedZoom: push is how far the camera goes in, above 1 (got ${push})`);
- if (!(o.exitF >= 2) || !(o.entryF >= 2)) throw new Error(`matchedZoom: an exit and an entry need at least 2 frames each (got ${o.exitF} and ${o.entryF})`);
+ if (!(o.exitF >= 2) || !(o.entryF >= 2) || !Number.isFinite(o.exitF) || !Number.isFinite(o.entryF)) throw new Error(`matchedZoom: an exit and an entry need at least 2 frames each (got ${o.exitF} and ${o.entryF})`);
const lp = Math.log(push), rate = exitSpeed(lp, o.exitF), lf = -entryDistance(rate, o.entryF);
+ // the incoming shot opens small and has to be painted that much wider than the frame: under 0.4 no scene is
+ if (!(Math.exp(lf) >= MIN_ZOOM_FROM)) throw new Error(`matchedZoom: the incoming shot would open at ${Math.exp(lf).toFixed(2)} of its size (the least is ${MIN_ZOOM_FROM}): push less, lengthen the exit or shorten the entry`);
return {
rate, from: Math.exp(lf),
- out: (local, cut) => Math.exp(lp * easeIn(ramp(local, cut - o.exitF, cut))),
+ out: (local, cut) => Math.exp(lp * easeIn(ramp(local, cut - 1 - o.exitF, cut - 1))),
in: (local, cut) => Math.exp(lf * (1 - easeOut(ramp(local, cut, cut + o.entryF)))),
};
};
@@ -76,15 +84,17 @@ export const speedCeiling = (W: number, fps: number) => (2.5 * W) / fps;
export type SeamFinding = { level: "warn" | "error"; msg: string; fix: string };
/**
- * Does motion carry across a cut? `a` is the screen velocity on the last frame before it, `b` on the
- * first frame after, both in screen px per frame. Empty when the seam holds.
+ * Does motion carry across a cut? `a` is the screen velocity of the outgoing shot's last step on screen
+ * (into frame cut - 1), `b` of the incoming shot's first (out of frame cut), in screen px per frame.
+ * Empty when the seam holds. A turn of more than 30 degrees counts as a turn.
*/
export const checkSeam = (a: P, b: P, o: { W: number; fps: number; rest?: number }): SeamFinding[] => {
+ if (![...a, ...b, o.W, o.fps].every(Number.isFinite) || !(o.W > 0) || !(o.fps > 0)) throw new Error(`checkSeam: velocities, W and fps must be numbers, W and fps above 0 (got [${a}], [${b}], W ${o.W}, fps ${o.fps})`);
const out: SeamFinding[] = [], va = Math.hypot(a[0], a[1]), vb = Math.hypot(b[0], b[1]), rest = o.rest ?? 0.5, top = speedCeiling(o.W, o.fps), r1 = (v: number) => v.toFixed(1);
if (va <= rest && vb <= rest) return out; // both at rest: a plain cut, judged by what it matches, not by this
if (va <= rest || vb <= rest) out.push({ level: "error", msg: `one side of the cut is at rest and the other is moving (${r1(va)} then ${r1(vb)} px a frame): it reads as a jerk`, fix: "bring both sides to rest, or open the incoming shot at the outgoing speed (matchedMove)" });
else {
- if (a[0] * b[0] + a[1] * b[1] <= 0) out.push({ level: "error", msg: "the direction of travel turns at the cut", fix: "keep one screen direction across the seam" });
+ if ((a[0] * b[0] + a[1] * b[1]) / (va * vb) < Math.cos(Math.PI / 6)) out.push({ level: "error", msg: "the direction of travel turns at the cut", fix: "keep one screen direction across the seam" });
const ratio = vb / va;
if (ratio < 0.7 || ratio > 1.4) out.push({ level: "warn", msg: `the speed ${ratio < 1 ? "drops" : "jumps"} at the cut (${r1(va)} then ${r1(vb)} px a frame)`, fix: "size the entry with entryDistance(exit speed, entry frames)" });
}
@@ -97,7 +107,7 @@ export type PlannedSeam = { type: string; cut?: boolean; signature?: boolean };
/** A designed seam used a third time has turned into a preset. Cuts are exempt; the signature move gets three (open, middle, close). */
export const checkSeamPlan = (plan: PlannedSeam[]): SeamFinding[] => {
const out: SeamFinding[] = [], n = new Map<string, { count: number; sig: boolean }>();
- for (const s of plan) { if (s.cut) continue; const e = n.get(s.type) ?? { count: 0, sig: false }; e.count++; e.sig ||= !!s.signature; n.set(s.type, e); }
+ for (const s of plan) { if (s.cut) continue; const type = s.type.trim().toLowerCase(), e = n.get(type) ?? { count: 0, sig: false }; e.count++; e.sig ||= !!s.signature; n.set(type, e); }
const sigs = [...n].filter(([, e]) => e.sig);
if (sigs.length > 1) out.push({ level: "warn", msg: `${sigs.length} signature moves (${sigs.map(([t]) => t).join(", ")})`, fix: "a film has one move that is its own" });
for (const [type, e] of n) { const max = e.sig ? 3 : 2; if (e.count > max) out.push({ level: "warn", msg: `"${type}" is used ${e.count} times`, fix: e.sig ? "the signature move belongs at the open, the middle and the close" : "use it for the two seams that matter most and give the others a seam of their own" }); }
diff --git a/skills/anidoodle/engine/test/arc.test.ts b/skills/anidoodle/engine/test/arc.test.ts
index d8ae126..b6a22d3 100644
--- a/skills/anidoodle/engine/test/arc.test.ts
+++ b/skills/anidoodle/engine/test/arc.test.ts
@@ -30,8 +30,13 @@ export const run = (ok: (cond: boolean, label: string) => void) => {
const loop = arcReport(tone(12, (t) => (t < 6 ? -24 : -18)), SR, { loop: true });
ok(has(loop, "where the loop comes round") && !has(loop, "out-shouts") && !has(loop, "build to"), `a loop that ends 6 LU over where it starts is flagged at the seam only (${loop.seamJump.toFixed(1)} LU)`);
ok(arcReport(tone(12, (t) => (t < 4 ? -24 : t < 8 ? -18 : -24)), SR, { loop: true }).findings.length === 0, "a loop that swells in the middle and returns has nothing to answer");
+ // a phrase that ends into a quiet bar: the join is no bigger a step than the piece makes inside itself
+ const breath = arcReport(tone(12, (t) => (t < 3 ? -30 : t < 6 ? -18 : t < 9 ? -30 : -21)), SR, { loop: true }); ok(breath.seamJump > 3 && breath.insideJump >= breath.seamJump && !has(breath, "comes round"), `a loop whose join steps ${breath.seamJump.toFixed(1)} LU is left alone when it steps ${breath.insideJump.toFixed(1)} LU inside too`);
// 4. short pieces and silence do not crash or nag
ok(arcReport(tone(3, () => -20), SR).findings.length === 0, "a three-second sting is not asked for an arc");
- const quiet = arcReport([new Float32Array(SR * 2), new Float32Array(SR * 2)], SR); ok(Number.isFinite(quiet.peakS) && quiet.findings.length === 0, "silence gives finite numbers and no findings");
+ const quiet = arcReport([new Float32Array(SR * 2), new Float32Array(SR * 2)], SR); ok(Number.isFinite(quiet.peakS) && quiet.findings.length === 0 && !arcText(quiet).includes("NaN"), "two seconds of silence give finite numbers and no findings");
+ const long = arcReport([new Float32Array(SR * 24), new Float32Array(SR * 24)], SR), longLoop = arcReport([new Float32Array(SR * 24)], SR, { loop: true }); ok(long.findings.length === 0 && longLoop.findings.length === 0 && !arcText(long).includes("NaN"), "24 seconds of silence are not told they lack a high point");
+ let threw = false; try { arcReport([], SR); } catch { threw = true; } ok(threw, "no channels at all is refused with a message");
+ ok(!arcText(arcReport(tone(2, () => -20), SR)).includes("NaN"), "a two-second piece prints no NaN");
};
diff --git a/skills/anidoodle/engine/test/sampler.test.ts b/skills/anidoodle/engine/test/sampler.test.ts
index 7fe0390..91eb8d6 100644
--- a/skills/anidoodle/engine/test/sampler.test.ts
+++ b/skills/anidoodle/engine/test/sampler.test.ts
@@ -1,6 +1,5 @@
// Tiny synthetic recordings: pitch, dynamics, dampers, bank routing and cache identity, no files.
-import { registerBank, bankFor, clearBanks, samplerVoice, sampleZones, sampleCutoff, sampleGain, bankIdentity, type SampleBank, type SampleZone } from "../src/canvas-core/music/sampler";
-import { pinnedPitch } from "../src/canvas-core/music/sampler";
+import { registerBank, bankFor, clearBanks, samplerVoice, sampleZones, sampleCutoff, sampleGain, bankIdentity, type SampleBank, type SampleZone, pinnedPitch } from "../src/canvas-core/music/sampler";
import { renderPiece, voiceJobs, runVoiceJob, voiceJobKey, calibrateBank } from "../src/canvas-core/music/render";
import { nocturne } from "../src/canvas-core/music/pieces/nocturne";
import { marimbaCurious } from "../src/canvas-core/music/pieces/families";
@@ -196,4 +195,5 @@ export const run = (ok: (cond: boolean, label: string) => void) => {
// a drum pinned to a note lands inside what was recorded, on the same note name
ok(pinnedPitch(31, [37, 59]) === 43 && pinnedPitch(60, [37, 59]) === 48 && pinnedPitch(43, [37, 59]) === 43, "a pinned pitch moves by octaves into the recorded range (G1 to G2, C4 to C3) and stays put when it is inside");
ok([24, 31, 38, 60, 72, 90].every((p) => { const q = pinnedPitch(p, [37, 59]); return q >= 37 && q <= 59 && (q - p) % 12 === 0; }), "every pinned pitch stays in range and keeps its note name");
+ { let threw = 0; for (const bad of [NaN, Infinity, -Infinity]) try { pinnedPitch(bad, [37, 59]); } catch { threw++; } ok(threw === 3, "a pinned pitch that is not a number is refused, never looped on"); }
};
diff --git a/skills/anidoodle/engine/test/seams.test.ts b/skills/anidoodle/engine/test/seams.test.ts
index dd3c06f..35396a4 100644
--- a/skills/anidoodle/engine/test/seams.test.ts
+++ b/skills/anidoodle/engine/test/seams.test.ts
@@ -1,7 +1,7 @@
// SEAM TESTS. src/canvas-core/seams.ts is arithmetic, so the claim it makes (motion carries across
// the cut at one speed, in one direction, and comes to rest exactly) is held to numbers here.
// node tools/test.mjs seams
-import { checkSeam, checkSeamPlan, easeIn, easeOut, entryDistance, exitSpeed, matchedMove, matchedZoom, speedCeiling, velocityAt } from "../src/canvas-core/seams";
+import { checkSeam, checkSeamPlan, easeIn, easeOut, entryDistance, exitSpeed, matchedMove, matchedZoom, MIN_ZOOM_FROM, speedCeiling, velocityAt } from "../src/canvas-core/seams";
import type { P } from "../src/canvas-core/core";
export const name = "seams";
@@ -18,33 +18,37 @@ export const run = (ok: (cond: boolean, label: string) => void) => {
// 2. a matched move: one speed on both sides of the cut, in one direction, at rest at both ends
for (const dir of [0, Math.PI, 0.6, -Math.PI / 2]) {
const m = matchedMove({ dir, exitDist: 260, exitF: 12, entryF: 40 });
- // one continuous path for the test: the incoming shot's rest is wherever the outgoing one left off, plus the entry
- const pos = (f: number): P => { if (f <= CUT) return m.out(f, CUT); const e = m.in(f, CUT), end = m.out(CUT, CUT); return [end[0] + e[0] + m.entryDist * Math.cos(dir), end[1] + e[1] + m.entryDist * Math.sin(dir)]; };
- const a = velocityAt(pos, CUT), b = velocityAt(pos, CUT + 1), va = Math.hypot(a[0], a[1]), vb = Math.hypot(b[0], b[1]);
+ // what is on screen: the outgoing shot up to CUT - 1, the incoming one from CUT. Each side's own step, as a viewer sees it
+ const a = velocityAt((f) => m.out(f, CUT), CUT - 1), b = velocityAt((f) => m.in(f, CUT), CUT + 1), va = Math.hypot(a[0], a[1]), vb = Math.hypot(b[0], b[1]);
ok(near(va, m.speed, 1e-6) && near(vb, m.speed, 1e-6), `dir ${dir.toFixed(2)}: ${va.toFixed(2)} px a frame into the cut, ${vb.toFixed(2)} out of it`);
ok(near(Math.atan2(a[1], a[0]), Math.atan2(b[1], b[0]), 1e-6), `dir ${dir.toFixed(2)}: the direction of travel is the same on both sides`);
ok(checkSeam(a, b, { W: 1920, fps: 30 }).length === 0, `dir ${dir.toFixed(2)}: checkSeam has nothing to say`);
- const s = m.out(CUT - 12, CUT), e = m.in(CUT + 40, CUT), late = m.in(CUT + 400, CUT), early = m.out(0, CUT);
+ const s = m.out(CUT - 13, CUT), e = m.in(CUT + 40, CUT), late = m.in(CUT + 400, CUT), early = m.out(0, CUT), end = m.out(CUT - 1, CUT);
ok(near(Math.hypot(s[0], s[1]), 0) && near(Math.hypot(early[0], early[1]), 0) && near(Math.hypot(e[0], e[1]), 0) && near(Math.hypot(late[0], late[1]), 0), `dir ${dir.toFixed(2)}: at rest before the exit and from the end of the entry on`);
+ ok(near(Math.hypot(end[0], end[1]), 260, 1e-9), `dir ${dir.toFixed(2)}: the whole exit is travelled by the outgoing shot's last frame on screen, CUT - 1`);
const last = velocityAt((f) => m.in(f, CUT), CUT + 40); ok(Math.hypot(last[0], last[1]) < m.speed * 0.01, `dir ${dir.toFixed(2)}: it lands with no speed left`);
}
- let mono = true; { const m = matchedMove({ exitDist: 260, exitF: 12, entryF: 40 }); for (let f = CUT - 12; f < CUT + 40; f++) if (f !== CUT && (f < CUT ? m.out(f + 1, CUT)[0] < m.out(f, CUT)[0] : m.in(f + 1, CUT)[0] < m.in(f, CUT)[0])) mono = false; }
+ let mono = true; { const m = matchedMove({ exitDist: 260, exitF: 12, entryF: 40 }); for (let f = CUT - 13; f < CUT + 40; f++) if (f !== CUT - 1 && (f < CUT - 1 ? m.out(f + 1, CUT)[0] < m.out(f, CUT)[0] : m.in(f + 1, CUT)[0] < m.in(f, CUT)[0])) mono = false; }
ok(mono, "neither side ever travels backwards");
- ok(throws(() => matchedMove({ exitDist: 100, exitF: 1, entryF: 20 })) && throws(() => matchedMove({ exitDist: 100, exitF: 10, entryF: 0 })), "a one-frame exit or a zero-frame entry is refused");
+ ok(throws(() => matchedMove({ exitDist: 100, exitF: 1, entryF: 20 })) && throws(() => matchedMove({ exitDist: 100, exitF: 10, entryF: 0 })) && throws(() => matchedMove({ exitDist: NaN, exitF: 10, entryF: 20 })) && throws(() => matchedMove({ exitDist: 100, exitF: Infinity, entryF: 20 })), "a one-frame exit, a zero-frame entry, an endless exit or a distance that is not a number is refused");
+ // the card's own numbers at 30 fps: a 0.2 s exit and a 0.5 s entry, measured on the frames a viewer sees
+ { const m = matchedMove({ exitDist: 260, exitF: 6, entryF: 15 }), a = velocityAt((f) => m.out(f, CUT), CUT - 1), b = velocityAt((f) => m.in(f, CUT), CUT + 1); ok(near(a[0], b[0], 1e-6) && checkSeam(a, b, { W: 1920, fps: 30 }).some((x) => x.msg.includes("past what blur")) === (a[0] > speedCeiling(1920, 30)), `a 6-frame exit and a 15-frame entry: ${a[0].toFixed(1)} px a frame on both displayed sides`); }
// 3. a matched zoom: the same rate of growth on both sides, in log space, landing on 1
const z = matchedZoom({ push: 1.2, exitF: 6, entryF: 15 });
- ok(near(z.out(CUT - 6, CUT), 1) && near(z.out(CUT, CUT), 1.2) && near(z.in(CUT, CUT), z.from) && near(z.in(CUT + 15, CUT), 1) && near(z.in(CUT + 99, CUT), 1), "zoom: 1 before, the push at the cut, `from` after it, 1 at rest");
- const rOut = Math.log(z.out(CUT, CUT) / z.out(CUT - 1, CUT)), rIn = Math.log(z.in(CUT + 1, CUT) / z.in(CUT, CUT));
+ ok(near(z.out(CUT - 7, CUT), 1) && near(z.out(CUT - 1, CUT), 1.2) && near(z.in(CUT, CUT), z.from) && near(z.in(CUT + 15, CUT), 1) && near(z.in(CUT + 99, CUT), 1), "zoom: 1 before, the push at the cut, `from` after it, 1 at rest");
+ const rOut = Math.log(z.out(CUT - 1, CUT) / z.out(CUT - 2, CUT)), rIn = Math.log(z.in(CUT + 1, CUT) / z.in(CUT, CUT));
ok(near(rOut, z.rate, 1e-9) && near(rIn, z.rate, 1e-9), `zoom: growing ${(100 * (Math.exp(rOut) - 1)).toFixed(1)}% a frame into the cut and ${(100 * (Math.exp(rIn) - 1)).toFixed(1)}% out of it`);
ok(z.from > 0.4 && z.from < 1, `zoom: the incoming shot opens at ${z.from.toFixed(2)} of its size, inside what a scene can be drawn at`);
ok(throws(() => matchedZoom({ push: 0.9, exitF: 6, entryF: 15 })) && throws(() => matchedZoom({ exitF: 1, entryF: 15 })), "a push of 1 or less, or a one-frame exit, is refused");
+ ok(throws(() => matchedZoom({ push: 2, exitF: 6, entryF: 30 })) && throws(() => matchedZoom({ push: 4, exitF: 2, entryF: 60 })) && matchedZoom({ push: 1.2, exitF: 6, entryF: 15 }).from >= MIN_ZOOM_FROM, `a zoom whose incoming shot would open under ${MIN_ZOOM_FROM} of its size is refused`);
// 4. checkSeam names each way a cut between moving shots goes wrong
const o = { W: 1920, fps: 30 }, has = (f: { msg: string }[], s: string) => f.some((x) => x.msg.includes(s));
ok(checkSeam([0, 0], [0.2, 0], o).length === 0, "two shots at rest: nothing to match");
ok(has(checkSeam([40, 0], [0, 0], o), "at rest") && has(checkSeam([0, 0], [40, 0], o), "at rest"), "one side at rest, one moving: flagged");
- ok(has(checkSeam([40, 0], [-40, 0], o), "turns") && has(checkSeam([40, 0], [0, 40], o), "turns"), "a reversal or a right-angle turn: flagged");
+ ok(has(checkSeam([40, 0], [-40, 0], o), "turns") && has(checkSeam([40, 0], [0, 40], o), "turns") && has(checkSeam([40, 0], [30, 26], o), "turns") && !has(checkSeam([40, 0], [39, 9], o), "turns"), "a reversal, a right angle and a 41 degree turn are flagged; 13 degrees is not");
+ ok(throws(() => checkSeam([NaN, 0], [40, 0], o)) && throws(() => checkSeam([40, 0], [40, 0], { W: 1920, fps: 0 })) && throws(() => checkSeam([40, 0], [40, 0], { W: undefined as unknown as number, fps: 30 })), "a velocity that is not a number, or a missing size or frame rate, is refused, never passed");
ok(has(checkSeam([40, 0], [20, 0], o), "drops") && has(checkSeam([40, 0], [80, 0], o), "jumps") && checkSeam([40, 0], [46, 0], o).length === 0, "half or double the speed is flagged; 15% off is not");
ok(near(speedCeiling(1920, 60), 80) && has(checkSeam([200, 0], [200, 0], o), "past what blur"), "the ceiling is 2.5 widths a second (80 px a frame at 1920 and 60 fps), and a move past it is flagged");
@@ -53,4 +57,5 @@ export const run = (ok: (cond: boolean, label: string) => void) => {
ok(checkSeamPlan([...p("iris", 2), ...p("matched cut", 6, { cut: true }), ...p("ink bloom", 3, { signature: true })]).length === 0, "two irises, six cuts and the signature three times pass");
ok(has(checkSeamPlan(p("iris", 3)), '"iris" is used 3 times') && has(checkSeamPlan(p("ink bloom", 4, { signature: true })), "4 times"), "a third iris and a fourth signature are flagged");
ok(has(checkSeamPlan([...p("bloom", 1, { signature: true }), ...p("wipe", 1, { signature: true })]), "2 signature moves"), "two signature moves are flagged");
+ ok(has(checkSeamPlan([{ type: "Iris" }, { type: "iris" }, { type: " iris " }]), "3 times"), "a seam is counted whatever its capitals and spaces");
};
diff --git a/skills/anidoodle/engine/tools/deck.mjs b/skills/anidoodle/engine/tools/deck.mjs
index fe04b5e..7288187 100644
--- a/skills/anidoodle/engine/tools/deck.mjs
+++ b/skills/anidoodle/engine/tools/deck.mjs
@@ -22,7 +22,7 @@ const rand = (seed) => { let a = seed >>> 0; return () => { a = (a + 0x6d2b79f5)
export const fits = (m, kind) => !kind || m.kinds.includes("any") || m.kinds.includes(kind);
export const weight = (m, energy) => ROLE_W[m.role] * (!energy || m.energy === energy ? 1 : m.energy === "any" ? 0.7 : 0.25);
-export const count = (seconds) => Math.max(4, Math.min(12, Math.round(seconds / 4)));
+export const count = (seconds) => Math.max(4, Math.min(12, Math.round(seconds / 4))); // a short film still gets an opening, a close and two more to choose from
/** A deal: one opening, one close, the rest spread over the middle categories in a shuffled order. */
export const deal = ({ kind, energy, seconds = 20, seed = 1, n, cat, avoid = [] } = {}) => {
const r = rand(seed), skip = new Set(avoid), picked = [];
@@ -49,18 +49,18 @@ const selfTest = () => {
walk(join(ROOT, "references")); walk(join(ROOT, "engine", "src")); walk(join(ROOT, "engine", "tools"));
const cited = [...new Set(M.flatMap((m) => `${m.build} ${m.not} ${m.move}`.match(/[A-Za-z0-9-]+\.(?:ts|mjs|md)\b/g) ?? []))], missing = cited.filter((f) => !have.has(f));
say(!missing.length, `all ${cited.length} files the cards cite exist${missing.length ? ` missing: ${missing.join(", ")}` : ""}`);
- say(!/[—]/.test(JSON.stringify(DECK)), "no em dashes in the deck");
+ say(!/\u2014/.test(JSON.stringify(DECK)), "no em dashes in the deck");
const key = (d) => d.map((m) => m.id).join(",");
say(key(deal({ kind: "story", energy: "high", seconds: 27, seed: 7 })) === key(deal({ kind: "story", energy: "high", seconds: 27, seed: 7 })), "the same seed deals the same hand");
say(new Set(Array.from({ length: 40 }, (_, s) => key(deal({ kind: "story", energy: "high", seconds: 27, seed: s + 1 })))).size >= 30, "forty seeds deal at least thirty different hands");
let rules = true, kinds = true, avoided = true, sizes = true;
for (let s = 1; s <= 300; s++) for (const kind of KINDS) {
const energy = ENERGY[s % 3], seconds = 6 + (s % 9) * 7, d = deal({ kind, energy, seconds, seed: s, avoid: ["cam-slow-push"] });
- if (d.filter((m) => m.cat === "open").length > 1 || d.filter((m) => m.cat === "close").length > 1 || d.filter((m) => m.role === "signature").length > 1 || new Set(d).size !== d.length) rules = false;
- if (!d.every((m) => fits(m, kind))) kinds = false; if (d.some((m) => m.id === "cam-slow-push")) avoided = false; if (d.length > count(seconds) || d.length < 3) sizes = false;
+ if (d.filter((m) => m.cat === "open").length !== 1 || d.filter((m) => m.cat === "close").length !== 1 || d.filter((m) => m.role === "signature").length > 1 || new Set(d).size !== d.length) rules = false;
+ if (!d.every((m) => fits(m, kind))) kinds = false; if (d.some((m) => m.id === "cam-slow-push")) avoided = false; if (d.length > 12 || d.length > count(seconds) || d.length < 3) sizes = false;
}
- say(rules, "2100 deals: one opening, one close, at most one signature card, no card twice");
- say(kinds, "no deal holds a card its kind of film cannot use"); say(avoided, "an avoided card is never dealt"); say(sizes, "a deal is never larger than a card every four seconds, never under three");
+ say(rules, "2100 deals: exactly one opening, exactly one close, at most one signature card, no card twice");
+ say(kinds, "no deal holds a card its kind of film cannot use"); say(avoided, "an avoided card is never dealt"); say(sizes, "a deal is a card every four seconds, never fewer than three and never more than twelve");
const tally = (energy) => { let hi = 0, n = 0; for (let s = 1; s <= 400; s++) for (const m of deal({ kind: "story", energy, seconds: 30, seed: s })) { n++; if (m.energy === "high") hi++; } return hi / n; };
say(tally("high") > tally("calm") * 1.5, `a high-energy film is dealt more high-energy cards than a calm one (${(tally("high") * 100).toFixed(0)}% against ${(tally("calm") * 100).toFixed(0)}%)`);
say(deal({ cat: "seam", n: 3, kind: "launch", seed: 3 }).every((m) => m.cat === "seam") && deal({ cat: "seam", n: 3, seed: 3 }).length === 3, "--cat deals from one category only");
@@ -68,14 +68,15 @@ const selfTest = () => {
};
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
- const [cmd, ...args] = process.argv.slice(2), val = (k) => { const i = args.indexOf(k); return i >= 0 ? args[i + 1] : undefined; }, num = (k) => (val(k) === undefined ? undefined : Number(val(k)));
const die = (m) => { console.error(`deck: ${m}`); process.exit(2); };
+ const [cmd, ...args] = process.argv.slice(2), val = (k) => { const i = args.indexOf(k); return i >= 0 ? args[i + 1] : undefined; };
+ const num = (k, least, whole) => { if (!args.includes(k)) return undefined; const x = Number(val(k)); if (val(k) === undefined || !Number.isFinite(x) || x < least || (whole && !Number.isInteger(x))) die(`${k} takes ${whole ? "a whole number" : "a number"} of ${least} or more (got ${val(k)})`); return x; };
if (cmd === "test") selfTest();
- else if (cmd === "list") { const c = val("--cat"); for (const m of DECK.moves.filter((m) => !c || m.cat === c)) console.log(`${m.id.padEnd(30)} ${m.cat.padEnd(9)} ${m.role.padEnd(10)} ${m.energy.padEnd(7)} ${m.kinds.join(",")}`); }
+ else if (cmd === "list") { const c = val("--cat"); if (c && !CATS.includes(c)) die(`--cat is one of ${CATS.join(", ")}`); for (const m of DECK.moves.filter((m) => !c || m.cat === c)) console.log(`${m.id.padEnd(30)} ${m.cat.padEnd(9)} ${m.role.padEnd(10)} ${m.energy.padEnd(7)} ${m.kinds.join(",")}`); }
else if (cmd === "deal") {
const kind = val("--kind"), energy = val("--energy"), c = val("--cat");
if (kind && !KINDS.includes(kind)) die(`--kind is one of ${KINDS.join(", ")}`); if (energy && !ENERGY.includes(energy)) die(`--energy is one of ${ENERGY.join(", ")}`); if (c && !CATS.includes(c)) die(`--cat is one of ${CATS.join(", ")}`);
- const seed = num("--seed") ?? (Date.now() % 100000), o = { kind, energy, seconds: num("--seconds") ?? 20, seed, n: num("--n"), cat: c, avoid: (val("--avoid") ?? "").split(",").filter(Boolean) }, d = deal(o);
+ const seed = num("--seed", 0, true) ?? (Date.now() % 100000), o = { kind, energy, seconds: num("--seconds", 1) ?? 20, seed, n: num("--n", c ? 1 : 3, true), cat: c, avoid: (val("--avoid") ?? "").split(",").filter(Boolean) }, d = deal(o);
if (args.includes("--json")) console.log(JSON.stringify({ ...o, cards: d }, null, 1));
else { console.log(`DECK seed ${seed}${kind ? ` · ${kind}` : ""}${energy ? ` · ${energy}` : ""}${c ? ` · ${c} only` : ` · ${o.seconds} s`} · ${d.length} cards\n`); console.log(d.map(card).join("\n\n")); console.log(`\nKeep, adapt or drop each card, and say why in the brief. To repeat this deal: --seed ${seed}. To deal the next film a different hand: --avoid ${d.map((m) => m.id).join(",")}`); }
} else die("usage: deck.mjs deal|list|test (see the header of this file)");
diff --git a/skills/anidoodle/engine/tools/music.mjs b/skills/anidoodle/engine/tools/music.mjs
index 8dc8004..6a8c439 100644
--- a/skills/anidoodle/engine/tools/music.mjs
+++ b/skills/anidoodle/engine/tools/music.mjs
@@ -232,7 +232,7 @@ const main = async () => {
const r = piece.plan.loop ? M.renderLoop(piece, SR, { cache, stems: true }) : M.renderPiece(piece, SR, { seconds, tempo, cache, stems: true }); T("mix"); const g = await pending; // stems: the peak note names the parts that pile up
const ok = [report(M, r, piece, cache, g.bands), printStems(M, piece, tempo, seconds, cache, g.stems)?.ok !== false];
T("report + stems"); { const cr = M.craftReport(piece, { centroidHz: M.centroid([r.L, r.R], SR).mean }); console.log(M.craftText(cr)); ok.push(!cr.findings.some((f) => f.level === "error")); } T("craft");
- { const pay = val("--payoff", undefined); console.log(M.arcText(M.arcReport([r.L, r.R], SR, { loop: !!piece.plan.loop, payoffS: pay }))); } // the shape of the finished sound: advisory, never fails the check
+ { const pay = val("--payoff", undefined); if (flag("--payoff") && !(pay >= 0)) { console.error("music: --payoff takes the second the picture pays off, e.g. --payoff 13.5"); process.exit(2); } console.log(M.arcText(M.arcReport([r.L, r.R], SR, { loop: !!piece.plan.loop, payoffS: pay }))); } // the shape of the finished sound: advisory, never fails the check
if (!pc.demo) { const fam = [args[0]]; ok.push(printNovelty(M, args[0], M.novelty(piece, M.DEMOS, fam), "shipped pieces")); }
console.log(ok.every(Boolean) ? "CHECK PASS: now a human listens (an mp3 or wav on a page)" : "CHECK FAIL: fix the items above, then run check again");
if (!ok.every(Boolean)) process.exitCode = 1; return;
diff --git a/skills/anidoodle/references/motion-deck.json b/skills/anidoodle/references/motion-deck.json
index 40f1bae..0c5f196 100644
--- a/skills/anidoodle/references/motion-deck.json
+++ b/skills/anidoodle/references/motion-deck.json
@@ -12,7 +12,7 @@
"not": "Centred on nothing. Or when the close also irises and a seam in the middle does: the third one is a preset." },
{ "id": "open-detail-first", "cat": "open", "role": "accent", "energy": "calm", "kinds": ["story", "loop", "drawing"],
"move": "Open so close on one detail (an eye, a hand, a nib) that the subject is not yet readable, then pull back over 1.5 to 3 s until it is.",
- "build": "Camera keys from zoom 4 to 6 down to 1 with monoZoom: true; divide stroke widths by weight(cam) so the close-up reads close, not enlarged (camera.md).",
+ "build": "Camera keys from zoom 4 to 6 down to 1 with monoZoom: true; divide stroke widths by cam.weight(cam.at(f)) so the close-up reads close, not enlarged (camera.md).",
"not": "A detail that was not drawn to be seen at that size. Check the first frame at --scale 2." },
{ "id": "open-cold-action", "cat": "open", "role": "accent", "energy": "high", "kinds": ["story", "launch"],
"move": "No establishing shot: the first frame is the middle of the action, and the wide shot comes second, as the answer to where we are.",
@@ -20,7 +20,7 @@
"not": "A calm piece, or a subject the viewer cannot name from the close shot within a second." },
{ "id": "seam-matched-cut", "cat": "seam", "role": "workhorse", "energy": "high", "kinds": ["any"],
- "move": "A hard cut hidden in travel. The outgoing shot accelerates over 0.2 to 0.4 s, the cut lands on its fastest frame, the incoming shot opens at the same speed in the same direction and comes to rest over 0.8 to 1.4 s.",
+ "move": "A hard cut hidden in travel. The outgoing shot accelerates over 0.2 to 0.4 s, its last frame is its fastest, the incoming shot opens at the same speed in the same direction and comes to rest over 0.8 to 1.4 s.",
"build": "matchedMove({ dir, exitDist, exitF, entryF }) in seams.ts, added to each scene's camera look; hold it with checkSeam. Render with --blur auto.",
"not": "Either shot has no room to travel, or the two travel different ways. Then both sides come to rest and it is a plain cut on a beat." },
{ "id": "seam-flight-through", "cat": "seam", "role": "accent", "energy": "high", "kinds": ["story", "launch", "explainer"],
@@ -112,7 +112,7 @@
{ "id": "type-written", "cat": "type", "role": "workhorse", "energy": "any", "kinds": ["launch", "explainer", "infographic"],
"move": "A line is written by its tool, one stroke after another, at the speed of a hand, and holds long enough to be read twice.",
- "build": "writeOn or sentence in kinetic.ts; on its own frame, or over a calm area that passes the poster test (workflows/launch-video.md, Type).",
+ "build": "writeOn or sentence in kinetic.ts; on its own frame, or over a calm area where the frame would pass as a poster (workflows/launch-video.md, Type).",
"not": "Over a face, the focal detail or busy texture. In doubt the line gets its own frame." },
{ "id": "type-one-line-at-a-time", "cat": "type", "role": "workhorse", "energy": "medium", "kinds": ["launch", "explainer"],
"move": "One line hands over to the next word by word, so there is never more than one full line on screen: the old line's words leave at twice the pace they came.",
diff --git a/skills/anidoodle/references/motion-grammar.md b/skills/anidoodle/references/motion-grammar.md
index cea8c67..0703bcd 100644
--- a/skills/anidoodle/references/motion-grammar.md
+++ b/skills/anidoodle/references/motion-grammar.md
@@ -137,15 +137,18 @@ roughest. The difference is arithmetic, and `engine/src/canvas-core/seams.ts` do
- **Both sides at rest, or both at one speed.** A cut from a moving shot to a still one (or the
other way) reads as a jerk. So does a cut where the travel turns, halves or doubles.
-- **Accelerate out, cut on the fastest frame, arrive and settle.** The outgoing shot speeds up
+- **Accelerate out, cut after the fastest frame, arrive and settle.** The outgoing shot speeds up
over about 0.2 to 0.4 s; the incoming shot opens at that same speed, in that same screen
direction, and comes to rest over 0.8 to 1.4 s. The exit is the short side.
`matchedMove({ dir, exitDist, exitF, entryF })` gives both halves, to add to each scene's
camera look; the entry distance is worked out from the exit speed, so the two always agree.
+ The incoming shot owns the cut frame: the outgoing shot's last frame on screen is the one
+ before it, and that is its fastest.
- **Through the cut, in depth.** `matchedZoom({ push, exitF, entryF })` does the same for a
camera that flies into one shot and out in the next. A zoom is a ratio, so both sides run in
- log space and grow at the same rate per frame across the cut. The incoming shot opens at
- about two thirds of its size, so its scene must be painted wider than the frame.
+ log space and grow at the same rate per frame across the cut. With the default push the
+ incoming shot opens at about two thirds of its size, so its scene must be painted that much
+ wider than the frame; a zoom that would open it under 0.4 is refused.
- **There is a top speed.** Past about two and a half frame widths a second
(`speedCeiling(W, fps)`), blur stops reading as motion and shows as a streak with stepped
copies. A move that needs more than that wants a shorter travel with the rest hidden behind
@@ -158,7 +161,7 @@ roughest. The difference is arithmetic, and `engine/src/canvas-core/seams.ts` do
eye sees a ghost. Move one object; change what it is at the middle of its trip.
`checkSeam(velocity before, velocity after, { W, fps })` returns what is wrong with a cut, or
-nothing. `checkSeamPlan` reads the film's list of seams and flags a designed seam used a third
+nothing: one side at rest, a turn of more than 30 degrees, a speed that drops or jumps. `checkSeamPlan` reads the film's list of seams and flags a designed seam used a third
time; plain and matched cuts are exempt, and the film's one signature move gets three (the open,
the middle, the close). Use this when both scenes have room to travel the same way. When they do
not, bring both to rest and cut on a beat.
diff --git a/skills/anidoodle/references/music/theory/form.md b/skills/anidoodle/references/music/theory/form.md
index 7baaab0..2726511 100644
--- a/skills/anidoodle/references/music/theory/form.md
+++ b/skills/anidoodle/references/music/theory/form.md
@@ -74,8 +74,9 @@ like `craft`: answer each finding, or say why the piece is that way on purpose.
- **The ending takes away.** The close is the most resolved moment, never the loudest: stop on a bar
line, a breath, one soft element, 8 to 20 dB under the peak. A loudest moment in the last fifth is
flagged.
-- **A loop has no beginning or end.** Only its contrast and its seam are read: the last second and the
- first must sit within 3 LU, or the join is heard every time it comes round.
+- **A loop has no beginning or end.** Only its contrast and its seam are read. The join is flagged when
+ the last second and the first differ by more than 3 LU and by more than any two neighbouring seconds
+ inside the piece: a phrase that ends into a quiet bar is the music, a step found nowhere else is a seam.
## 4. Orchestration: registers and frequency slots
diff --git a/skills/anidoodle/references/workflows/review.md b/skills/anidoodle/references/workflows/review.md
index d2d8629..8f95c12 100644
--- a/skills/anidoodle/references/workflows/review.md
+++ b/skills/anidoodle/references/workflows/review.md
@@ -13,12 +13,12 @@ Freeze a copy of the file and note its hash first. Every reading is of that copy
## The four readings
-| Reading | Looks at | Its question | Scores |
+| Reading | Looks at | What it settles | Scores |
|---|---|---|---|
-| **Director** | the contact sheet at one tile per beat, sound off; then each seam as a before/after pair | Would someone who has never seen the brief say what this film is about, and feel the payoff? | point, first second, pacing, seams |
-| **Illustrator** | full-size stills of the hardest frames; crops of faces, hands, feet and joins at `--scale 2` | Would a proud illustrator sign this, or is it shapes assembled (`craft-bar.md`)? | drawing, style |
-| **Motion and finish** | `popscan.mjs`, `gate.mjs`, strips of consecutive frames across every seam and every fast move | Does anything pop, stall, jump or smear that was not meant to? | motion, finish |
-| **Sound and sync** | `music.mjs check` (with its ARC line), `verify-export.mjs`, the cue table against the picture | Is the sound one piece with a shape, and does it land on the picture? | sound |
+| **Director** | the contact sheet at one tile per beat, sound off; then each seam as a before/after pair | Whether someone who has never seen the brief could say what the film is about, and feel the payoff. | point, first second, pacing, seams |
+| **Illustrator** | full-size stills of the hardest frames; crops of faces, hands, feet and joins at `--scale 2` | Whether a proud illustrator would sign it, or it is shapes assembled (`craft-bar.md`). | drawing, style |
+| **Motion and finish** | `popscan.mjs`, `gate.mjs`, strips of consecutive frames across every seam and every fast move | Whether anything pops, stalls, jumps or smears that was not meant to. | motion, finish |
+| **Sound and sync** | `music.mjs check` (with its ARC line), `verify-export.mjs`, the cue table against the picture | Whether the sound is one piece with a shape, and lands on the picture. | sound |
Rules that make a reading worth having:
@@ -43,8 +43,8 @@ Rules that make a reading worth having:
## The check before fixing
Before anything is changed, every P0 and P1 is looked at once more, at full size, by someone
-trying to prove it wrong: is it on the frame named, is it what the finding says, would a viewer
-see it. Some first-pass findings do not survive this, and each one that is "fixed" anyway
+trying to prove it wrong: it must be on the frame named, be what the finding says, and be
+something a viewer would see. Some first-pass findings do not survive this, and each one that is "fixed" anyway
costs a rebuild and risks something that worked. What survives goes on the list, ranked by how
much the film gains for the time the fix takes.