Archilyzer · Source

archilyzer

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

commit 88868b68b022da9e741d10f2163a6fc62af1a365
parent 267d96f6b9a61edd3e5c1a357f7737a292a0e455
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 10 Oct 2026 13:31:11 -0400

umtool: swap-clip refuses a clip the plan already plays, and one it cannot render

The reuse check compared exact keys, so a trimmed window of the same clip
(OlY74Y-NmMw@700.006 and @700.002) passed it, and FORCE skipped it entirely:
mk-plan-fatal5 played that clip on two consecutive melody notes, and had eight
same-clip repeats in all. Any overlap with a clip already in the plan now counts
as the same sound, in the ranked path and for FORCE (FORCE_REUSE=1 to allow it).

Candidates whose source has no media/ or wav48/ on this machine are skipped:
cand2/ and the palette outlive a re-download, and render-poly reads both.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/song/swap-clip.mjs | 20++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/umtool/song/swap-clip.mjs b/umtool/song/swap-clip.mjs @@ -20,10 +20,12 @@ // // F0_MAX=<Hz> reject candidates above this (default 200; 115 is the gate // arrange-poly uses to separate a guest from Jer) +// FORCE=<video@start> use this clip regardless of rank; refused if it overlaps a clip +// already in the plan unless FORCE_REUSE=1 // FLAT_MAX=<f> reject candidates whose spectral flatness exceeds this. // Measured lazily, best-scoring candidate first, because it // is an FFT per clip and the pool is thousands of clips. -import { readFileSync, writeFileSync, readdirSync } from "node:fs"; +import { existsSync, readFileSync, writeFileSync, readdirSync } from "node:fs"; import path from "node:path"; import { SONG_DATA } from "./paths.mjs"; import { readWavMono, spectralFlatness } from "./flatness.mjs"; @@ -78,6 +80,16 @@ all = all.filter((c) => acc.has(key(c)) && !seen.has(key(c)) && seen.add(key(c)) // every clip already sounding anywhere in this plan const used = new Set(plan.voices.flatMap((x) => x.plan.map((p) => `${p.video}@${p.srcStart}`))); +// The same clip is not only the same KEY: a trim (hush-head, a nudged window) moves a +// note's srcStart by milliseconds, and mk-plan-fatal5 played OlY74Y-NmMw@700.006 and +// @700.002 on two consecutive notes. Any overlap with a clip already in the plan is +// the same sound. +const usedSpans = plan.voices.flatMap((x) => x.plan.filter((p) => p.video).map((p) => [p.video, p.srcStart, p.srcEnd])); +const overlapsUsed = (c) => usedSpans.some(([vid, a, b]) => vid === c.video && c.start < b && a < c.end); +// A clip whose source is not on this machine cannot be rendered: the palette and +// cand2/ outlive a re-download, and render-poly reads media/ and wav48/. +const renderable = (vid) => existsSync(path.join(SONG_DATA, "wav48", `${vid}.wav`)) && + existsSync(path.join(SONG_DATA, "media", `${vid}.mp4`)); // ---- spectral flatness, for the STATIC case -------------------------------- // The measure itself lives in flatness.mjs, shared with plan-qa.mjs and the @@ -182,7 +194,8 @@ let skippedWords = 0; let skippedSuspect = 0; for (const c of all) { const k = key(c); - if (used.has(`${c.video}@${c.start}`)) continue; + if (used.has(`${c.video}@${c.start}`) || overlapsUsed(c)) continue; + if (!renderable(c.video)) continue; if (IMPURE.has(k)) continue; // plain clips only if (!ALLOW_WORDS && wordsInside(c).length) { skippedWords += 1; continue; } if (SUSPECT_KEYS.has(k)) { skippedSuspect += 1; continue; } @@ -230,6 +243,9 @@ let best = null; if (FORCE) { const c = all.find((x) => `${x.video}@${(+x.start).toFixed(2)}` === FORCE || `${x.video}@${x.start}` === FORCE); if (!c) throw new Error(`FORCE clip ${FORCE} is not in the palette`); + // FORCE skipped the reuse check entirely, which is how one clip played twice in a row. + if (overlapsUsed(c) && process.env.FORCE_REUSE !== "1") + throw new Error(`FORCE clip ${FORCE} is already in the plan (FORCE_REUSE=1 to allow it)`); const core = CORE[key(c)]; const dur = core ? core.dur : c.dur; const f0 = FORCE_F0 || (core ? core.f0 : c.f0);