Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 5a3c2576230edcb57848fdf2b155c8a5e178f4b4
parent 452519bb547a27312770bb151de8fbcac1d20695
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 23:55:14 -0500

Merge lane/analysis-ending (read time): an analysis item's reading line is on screen long enough to be read -- it comes in right after the line has drawn and stays fully lit for its read time before the dissolve out or the cut's closing fade; an item too short for its reading is refused, saying what to change

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mumtool/docs/report-video.md | 13++++++++++++-
Mumtool/report-to-video/analysis-build.test.mjs | 2+-
Mumtool/report-to-video/analysis-plan.mjs | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/report-to-video/chrome-analysis.mjs | 34+++++++++++++++++++++-------------
Mumtool/report-to-video/chrome-analysis.test.mjs | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++--------
5 files changed, 137 insertions(+), 23 deletions(-)

diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -519,7 +519,18 @@ plays at the clip's own level (its cut record's loudness gain under `render.loud `audio.gain`), faded in and out over 0.3 s. Its picture is not shown; its citation ("HEARD: channel · title · date · clock") and its QR are, at the foot. The item lasts exactly the span. The lint warns when the cut also plays that span (the words heard twice). Without audio the item is **silent for `seconds`** (default 7, -at most 8: no dead air); a short one's motion is scaled to leave a 1.5 s hold. Works with no model anywhere. +at most 8: no dead air). Works with no model anywhere. + +**The reading's time.** The reading comes in right after the line has drawn (the pace and status rows +landing beside it) and stays FULLY lit for its read time -- words × 0.3 s, at least 2.5 s, at most 5 s +(analysis-plan.mjs `ANALYSIS_READ`) -- before the picture starts to leave: the dissolve out to the next entry +(`render.transition`) or, when the item is the cut's last, the closing fade (`render.endFade`; the page is lit to +the final frame and the fade is the build's). The motion before it is scaled to fit (never below 0.45 of its pace: +the line still draws over a second, the fades are never hurried); when even that does not fit, the item is +refused: "the reading (25 words) needs 5 s on screen; the item is 7 s, its last 1 s the cut's closing fade -- +shorten the reading, raise seconds (≤ 8 silent) or put a clip's sound under it". The first use at 8 s silent +(`endFade` 1): the line draws 0.39–1.45 s, the reading is in at 1.5 s and fully lit at 2.0 s, every row landed +by 2.33 s, and the reading stays fully lit for 5 s until the fade at 7 s. **What fits.** The side panel holds **5 rows** (pace and status together; pace at most 5, status at most 2); the reading **two lines** -- about 185 characters, 160 beside the QR; the title 44, the kicker 64, the band's diff --git a/umtool/report-to-video/analysis-build.test.mjs b/umtool/report-to-video/analysis-build.test.mjs @@ -153,7 +153,7 @@ test("--cut-window over an analysis item: the whole cut's segments, then the win render: { width: 640, height: 360, fps: 10, transition: 0, audioRate: 48000, audioChannels: 2, ...FONTS }, ledgerSchema: { kind: "measure", unit: "lb", tracks: [{ key: "weight", role: "value" }] }, ledger: [W("w1", "current", "2026-09-01", 310), W("w2", "current", "2026-10-01", 300)], - timeline: [{ type: "analysis", id: "an", title: "The run", series: { rows: ["w1", "w2"] }, pace: [{ from: "w1", to: "w2" }], reading: "It went down.", seconds: 4 }], + timeline: [{ type: "analysis", id: "an", title: "The run", series: { rows: ["w1", "w2"] }, pace: [{ from: "w1", to: "w2" }], reading: "It went down.", seconds: 6 }], }; const dir = await mkdtemp(path.join(tmpdir(), "analysis-window-")); try { diff --git a/umtool/report-to-video/analysis-plan.mjs b/umtool/report-to-video/analysis-plan.mjs @@ -35,10 +35,47 @@ import { measureQualifier, measureSchema, plotDate } from "./measure-totals.mjs" import { playEdges } from "./mute.mjs"; import { gapsOf } from "./gaps.mjs"; import { trailLayout, trailLine } from "./trail-plan.mjs"; +import { endFadeOf, transitionOf } from "./deck.mjs"; /** The item's length: the silent default and ceiling (no dead air), the floor any item has, the longest audio. */ export const ANALYSIS_SECONDS = Object.freeze({ silent: 7, silentMax: 8, min: 4, audioMax: 30 }); +/** + * The page's motion, in seconds at full pace (chrome-analysis.mjs draws it): the title, the axes, the band, the line + * drawn point to point, then the READING right after the line, the pace and status rows landing beside it. A short + * item's motion is scaled by k (at least `kMin`: the line still draws, nothing slams) so the reading is fully lit for + * its read time (ANALYSIS_READ) before the picture starts to leave. + */ +export const ANALYSIS_MOTION = Object.freeze({ + title: 0.5, axes: 0.3, band: 0.8, lineFrom: 0.8, line: 2.2, point: 0.3, mark: 0.35, + rowGap: 0.25, row: 0.35, rowRise: 10, reading: 0.5, readGap: 0.1, foot: 0.2, kMin: 0.45, +}); + +/** Seconds from the item's start to its reading coming in, at full pace (k = 1); it is fully lit `reading` (its fade, never scaled) later. */ +export const READ_AFTER = ANALYSIS_MOTION.lineFrom + ANALYSIS_MOTION.line + ANALYSIS_MOTION.readGap; + +/** The reading's time fully on screen: `perWord` a word, at least `min`, at most `max` seconds. */ +export const ANALYSIS_READ = Object.freeze({ perWord: 0.3, min: 2.5, max: 5 }); + +/** The reading's words (a dash or a mark is no word). */ +export const readingWords = (s) => (String(s ?? "").match(/[\p{L}\p{N}][\p{L}\p{N}'’.,-]*/gu) ?? []).length; + +/** The reading's read time: words × perWord, clamped to [min, max]. */ +export const readHoldOf = (reading) => r2(Math.min(ANALYSIS_READ.max, Math.max(ANALYSIS_READ.min, readingWords(reading) * ANALYSIS_READ.perWord))); + +/** + * When the item's picture starts to LEAVE, in its own seconds: its length less what the build does at its end -- + * the dissolve out to the next segment (`render.transition`), or, when it is the cut's last entry, the cut's closing + * fade (`render.endFade`; 0: none, the page lit to the last frame). `{ leave, tail, last, seconds }`. + */ +export function analysisLeave(entry, timeline, render) { + const seconds = analysisSeconds(entry); + const tl = Array.isArray(timeline) ? timeline : []; + const last = tl.length > 0 && tl[tl.length - 1]?.id === entry?.id; + const tail = last ? endFadeOf(render ?? {}) : transitionOf(render ?? {}); + return { leave: r2(seconds - tail), tail, last, seconds }; +} + /** How many rows each table holds on the frame (`rows`: pace and status together, the side panel's room). */ export const ANALYSIS_LIMITS = Object.freeze({ pace: 5, status: 2, rows: 5, marks: 6, series: 120 }); @@ -316,6 +353,7 @@ export function analysisPlan(entry, ctx, box = { x0: 70, x1: 800, y0: 150, y1: 5 points, line: line.map((p) => p.n), pos, layout: { lo: L.lo, hi: L.hi, X: L.X, Y: L.Y, grid, months, mark, markRow: r.mark?.row ?? null, markLabel: r.mark?.label ?? null, markY: mark !== null ? L.Y(mark) : null }, band, marks, pace: r.pace, status: r.status, audio: r.audio, seconds: analysisSeconds(entry), + readHold: readHoldOf(entry.reading), readWords: readingWords(entry.reading), ...pickLeave(analysisLeave(entry, ctx?.timeline, ctx?.render)), first: points.length ? line[0] : null, last: points.length ? line[line.length - 1] : null, }; } @@ -602,9 +640,21 @@ function resolve(entry, { ledger = [], schema = null, timeline = [], render = {} else if (secs > ANALYSIS_SECONDS.silentMax) errors.push(`${at}: held ${secs} s with no audio (at most ${ANALYSIS_SECONDS.silentMax}: no dead air) -- shorten it or give it audio from a clip`); } if (analysisSeconds(entry) < ANALYSIS_SECONDS.min) errors.push(`${at}: ${analysisSeconds(entry)} s is too short to read (at least ${ANALYSIS_SECONDS.min})`); + // THE READING'S TIME: fully lit for its read time before the picture starts to leave, after the fastest calm + // motion (k = kMin) has brought it in. + if (typeof entry.reading === "string" && entry.reading.trim()) { + const lv = analysisLeave(entry, timeline, render); + const hold = readHoldOf(entry.reading); + if (lv.leave - hold < ANALYSIS_MOTION.kMin * READ_AFTER + ANALYSIS_MOTION.reading - 1e-6) { + errors.push(`${at}: the reading (${readingWords(entry.reading)} words) needs ${hold} s on screen; the item is ${lv.seconds} s` + + `${lv.tail ? `, its last ${lv.tail} s ${lv.last ? "the cut's closing fade" : "the dissolve out"}` : ""} -- shorten the reading, raise seconds (≤ ${ANALYSIS_SECONDS.silentMax} silent) or put a clip's sound under it`); + } + } return out; } +const pickLeave = (lv) => ({ leave: lv.leave, tail: lv.tail, last: lv.last }); + const pick = (p) => ({ row: p.row, date: p.date, value: p.value, qualifier: p.qualifier }); const isoOf = (day) => new Date(day * 86400000).toISOString().slice(0, 10); diff --git a/umtool/report-to-video/chrome-analysis.mjs b/umtool/report-to-video/chrome-analysis.mjs @@ -14,25 +14,30 @@ // interpreter, measure-draw.mjs pageHtml/cueList -- seekable from either side). import { colorsOf, fontStack } from "./chrome-instruments.mjs"; import { mix, rgba } from "./chrome-deck.mjs"; -import { analysisPlan } from "./analysis-plan.mjs"; +import { ANALYSIS_MOTION, READ_AFTER, analysisPlan } from "./analysis-plan.mjs"; import { cueList, esc, fmtWeight, pageHtml, r4 } from "./measure-draw.mjs"; -/** The motion's seconds (at full length; a short item's motion is scaled to leave ANALYSIS_MOTION.hold at the end). */ -export const ANALYSIS_MOTION = Object.freeze({ - title: 0.5, axes: 0.3, band: 0.8, lineFrom: 0.8, line: 2.2, point: 0.3, mark: 0.35, - rowGap: 0.25, row: 0.35, rowRise: 10, reading: 0.5, hold: 1.5, -}); +/** The motion's seconds: analysis-plan.mjs's (one copy, with the reading's time). */ +export { ANALYSIS_MOTION }; /** The frame, in the 1280x720 units the page is laid out in (scaled to the render). */ export const ANALYSIS_BOX = Object.freeze({ x0: 70, x1: 800, y0: 150, y1: 560, panel: 850, panelR: 1230, qr: 140 }); -/** When each thing lands, in the item's own seconds: `{ title, axes, band, points: Map(n -> t), marks, rows: [t], reading, foot, end }`. */ +/** + * When each thing lands, in the item's own seconds: `{ k, title, axes, band, points: Map(n -> t), rows: [t], reading, + * foot, readLit, end, leave, readHold }`. The title, the axes and the band; the line drawn point to point; then the + * READING right after the line (fully lit at `readLit`) with the pace and status rows landing beside it, one after + * another. Scaled by k = min(1, (leave − readHold − its fade) / READ_AFTER), at least kMin (the fades are never + * scaled: nothing hurries), so the reading stays fully lit for + * `readHold` before the picture starts to leave (`leave`: the dissolve out, or the cut's closing fade when last). + */ export function analysisTimes(plan) { const M = ANALYSIS_MOTION; const line = plan.line.map((n) => plan.pos.get(n)); const span = line.length > 1 ? line.reduce((s, p, i) => (i ? s + Math.hypot(p.x - line[i - 1].x, p.y - line[i - 1].y) : 0), 0) : 0; - const natural = M.lineFrom + M.line + 0.1 + (plan.pace.length + plan.status.length) * M.rowGap + M.row + 0.1 + M.reading + 0.2; - const k = Math.min(1, Math.max(0.4, (plan.seconds - M.hold) / natural)); + const leave = Number.isFinite(plan.leave) ? plan.leave : plan.seconds; + const readHold = Number.isFinite(plan.readHold) ? plan.readHold : 0; + const k = Math.min(1, Math.max(M.kMin, (leave - readHold - M.reading) / READ_AFTER)); const at = (v) => r4(v * k); const points = new Map(); let walked = 0; @@ -42,10 +47,13 @@ export function analysisTimes(plan) { }); // A point that is not on the line (another weight for its day): with the line's point that day. for (const p of plan.points) if (!points.has(p.n)) points.set(p.n, points.get(plan.line.find((n) => plan.points[n].day === p.day)) ?? at(M.lineFrom)); - const rowsFrom = M.lineFrom + M.line + 0.1; - const rows = [...plan.pace, ...plan.status].map((_, i) => at(rowsFrom + i * M.rowGap)); - const reading = at(rowsFrom + rows.length * M.rowGap + M.row + 0.1); - return { k, title: 0, axes: at(0.3), band: at(M.band), points, rows, reading, foot: r4(reading + at(0.2)), end: r4(reading + at(M.reading + 0.2)) }; + const after = M.lineFrom + M.line + M.readGap; + const reading = at(after); + const rows = [...plan.pace, ...plan.status].map((_, i) => at(after + i * M.rowGap)); + const readLit = r4(reading + M.reading); + const foot = r4(reading + at(M.foot)); + const end = r4(Math.max(readLit, foot + M.reading, rows.length ? rows[rows.length - 1] + M.row : 0)); + return { k, title: 0, axes: at(0.3), band: at(M.band), points, rows, reading, foot, readLit, end, leave, readHold }; } /** diff --git a/umtool/report-to-video/chrome-analysis.test.mjs b/umtool/report-to-video/chrome-analysis.test.mjs @@ -4,7 +4,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { analysisCite, analysisHtml, analysisTimes } from "./chrome-analysis.mjs"; -import { analysisPlan } from "./analysis-plan.mjs"; +import { ANALYSIS_MOTION, analysisPlan, analysisProblems, readHoldOf, readingWords } from "./analysis-plan.mjs"; const SCHEMA = { kind: "measure", unit: "lb", bandGapDays: 60, @@ -71,21 +71,66 @@ test("calm: no overshoot ease, nothing scaled past its size, every cue inside th for (const [k, v] of Object.entries(init)) if (v.scale !== undefined) assert.ok(v.scale <= 1, k); }); -test("the line reaches each point in date order; the rows land after it, the reading last", () => { +test("the line reaches each point in date order; then the reading, the rows landing beside it", () => { const plan = analysisPlan(ITEM, CTX); const T = analysisTimes(plan); const ts = plan.line.map((n) => T.points.get(n)); assert.deepEqual([...ts].sort((a, b) => a - b), ts); + // The line draws: at least kMin of its 2.2 s, never instant. + assert.ok(ts.at(-1) - ts[0] >= ANALYSIS_MOTION.kMin * ANALYSIS_MOTION.line - 1e-6); + assert.ok(T.reading >= ts.at(-1)); assert.ok(T.rows[0] >= ts.at(-1)); - assert.ok(T.reading > T.rows.at(-1)); assert.ok(T.end <= plan.seconds); }); -test("a short silent item's motion is scaled to leave its hold", () => { - const plan = analysisPlan({ ...ITEM, seconds: 5 }, CTX); - const T = analysisTimes(plan); - assert.ok(T.k < 1); - assert.ok(T.end <= 5 - 1 + 1e-6, `ends ${T.end}`); +// THE READING'S TIME (rev9-a10 R2: a 25-word reading lit for about a second before the closing fade): fully lit for +// readHold = clamp(words × 0.3, 2.5, 5) before the picture starts to leave -- the dissolve out, or the cut's +// closing fade when the item is last. +const FIRST = "By his own numbers the loss is steady — and it stalled for two weeks around the World Series, exactly when the scale video was promised."; +const timing = (entry, { last = true, endFade = 1, transition = 0.4 } = {}) => { + const render = { ...CTX.render, endFade, transition }; + const timeline = last ? [...CTX.timeline, entry] : [...CTX.timeline, entry, { type: "card", id: "next", seconds: 3 }]; + const ctx = { ...CTX, render, timeline }; + const problems = analysisProblems(entry, ctx); + if (problems.errors.length && process.env.DBG) console.log(problems.errors); + return { problems, T: analysisProblems(entry, ctx).errors.length ? null : analysisTimes(analysisPlan(entry, ctx)) }; +}; +const litFor = (T) => T.leave - T.readLit; + +test("the reading is fully lit for its read time before the picture leaves: 8 s, a 14.5 s audio item, a short reading, mid-cut", () => { + assert.equal(readHoldOf(FIRST), 5); + assert.equal(readingWords(FIRST), 25); + assert.equal(readHoldOf("It went down."), 2.5); + // The first use, last in the cut (render.endFade 1): at 8 s the reading is lit 5 s before the fade begins. + const eight = timing({ ...ITEM, reading: FIRST, seconds: 8 }).T; + assert.equal(eight.leave, 7); + assert.ok(litFor(eight) >= 5 - 1e-6, JSON.stringify({ readLit: eight.readLit, leave: eight.leave, k: eight.k })); + assert.ok(eight.k >= ANALYSIS_MOTION.kMin && eight.k < 1); + // With a clip's sound under it, 14.5 s: full pace, the reading lit long before the end. + const audio = timing({ ...ITEM, reading: FIRST, audio: { clip: "c46", start: 110, end: 124.5 } }).T; + assert.equal(audio.k, 1); + assert.ok(litFor(audio) >= 5); + // A short reading at 7 s: 2.5 s is enough, the motion at full pace or near it. + const short = timing({ ...ITEM, reading: "It went down.", seconds: 7 }).T; + assert.ok(litFor(short) >= 2.5 - 1e-6); + // Mid-cut, the dissolve out (0.4 s) is the leave point. + const mid = timing({ ...ITEM, reading: FIRST, seconds: 8 }, { last: false }).T; + assert.equal(mid.leave, 7.6); + assert.ok(litFor(mid) >= 5 - 1e-6); + // The longest reading the frame takes (185 characters) at the longest silent item (8 s): it fits. + const longest = "word ".repeat(37).trim(); + assert.equal(longest.length, 184); + const lt = timing({ ...ITEM, reading: longest, seconds: 8 }).T; + assert.ok(lt && litFor(lt) >= readHoldOf(longest) - 1e-6); + // No closing fade: the page is lit to the last frame. + const nofade = timing({ ...ITEM, reading: FIRST, seconds: 8 }, { endFade: 0 }).T; + assert.equal(nofade.leave, 8); +}); + +test("a reading that cannot be read in the item is refused, saying what it needs", () => { + const { problems } = timing({ ...ITEM, reading: FIRST, seconds: 7 }); + assert.ok(problems.errors.some((e) => e.includes("the reading (25 words) needs 5 s on screen; the item is 7 s, its last 1 s the cut's closing fade -- shorten the reading, raise seconds (≤ 8 silent) or put a clip's sound under it")), problems.errors.join("\n")); + assert.ok(timing({ ...ITEM, reading: "It went down.", seconds: 4 }, { endFade: 0 }).problems.errors.some((e) => /the reading \(3 words\) needs 2\.5 s on screen; the item is 4 s --/.test(e))); }); test("with audio: the citation line and the code", () => {