aqua-feel sync ramp: measure and print, never give a verdict
A second Soul pass falsified the late claim: one outlier raw frame before the true start moves the upper bound earlier (wrong at true lags 4-97 ms on heavy-tailed noise, 3% outlier frames, keyframe-style spikes), and a bed that swells near a hit takes over the pairing. After the first pass removed the early and inside claims, nothing is left that a ramp can soundly assert about sync, so every ramp pair is borderline and never fails the gate. The estimate and interval are printed for a person to read. Tests: the outlier frame and the swelling bed, both with a true lag the old verdict got wrong. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
33af5110ed
commit
39b5f96e0a
3 changed files with 21 additions and 15 deletions
|
|
@ -76,12 +76,11 @@ Some visuals answer a sound with a slow swell (a scene brightening over a few hu
|
|||
(`step` found 0 of 5 hits on `fixtures/perlines-trails-ramp.webm`; `ramp` paired 3). `--shape ramp` takes the track's rise over 300 ms as the novelty and picks its peaks (at least 15% of the track's range, 6 noise sigmas,
|
||||
at least 500 ms apart). For each it finds the quiet level before the rise (the last sample within 2 noise sigmas of the minimum of the 0.6 s before) and the 20% and 80% crossings of the rise to its top.
|
||||
|
||||
**What it claims.** Only this, and only in one direction. The picture had started to change by the first frame whose raw value stood above the quiet level by 20% of the rise (and at least 4 noise sigmas): `hiS`. If the sound still came
|
||||
later than the window after that frame, the verdict is `audio-late-detectable`; that claim does not depend on the ramp's shape. Everything else is `borderline`, always: **a ramp is never reported `inside-window` or `audio-early-detectable`,**
|
||||
because the start of a swell cannot be bounded from below by looking at it (a slow start sits under the noise; the same sound can sit 0 to 300 ms after the real start). The report still prints a lag interval, from `hiS` back to the quiet
|
||||
minimum backed off by the valley-to-crossing time and one frame; the back-off is a heuristic that held on the synthetic sweep, not a bound, and no verdict leans on it. The point value (`visual s`, `lag ms`) is the foot of the line through
|
||||
the 20% and 80% crossings: it fits a linear ramp, reads early for exponential approach and late for slow-start shapes, and is not the instant anyone perceives. The synthetic sweep (`sync.test.mjs`, 120 shapes x rises 40..800 ms x decays x 24..120 fps x
|
||||
noise x offsets) never produces a wrong ramp verdict; a Soul pass found two earlier versions that did (a centred 60 ms average crossing before the picture; the lower bound taken as a bound).
|
||||
**What it claims.** That a swell-shaped response was found near each sound, and where: a point estimate (`visual s`, `lag ms`: the foot of the line through the 20% and 80% crossings of the rise) and a printed interval (from the quiet minimum, backed off by
|
||||
the valley-to-crossing time, to the first raw frame 20% of the rise above the quiet level). **It makes no claim about sync: every ramp pair is `borderline`, and a ramp can never fail the gate.** Two separate-context Soul passes falsified every stronger claim
|
||||
the first versions made. The start of a swell cannot be bounded from below by looking at it (a slow start sits under the noise), so "inside the window" and "audio early" were wrong on slow-start shapes; the upper bound is moved earlier by one outlier frame
|
||||
(a compression spike, a heavy-tailed noise frame), so "audio late" was wrong at true lags of 4 to 97 ms on realistic noise; and a bed that swells near a hit takes over the pairing. The numbers are for a person to read next to the capture, not a verdict.
|
||||
The synthetic sweep and the outlier-frame and swelling-bed cases are tests that no ramp gets a verdict other than `borderline`.
|
||||
|
||||
**What it cannot claim.** That the sound is in sync with a swell (only that it is not detectably late). When the viewer sees the swell begin (later than the physical start; depends on contrast, size and attention). That the swell was caused by this sound: pairing
|
||||
is by nearness to the foot, and a bed that swells on its own, a scene change or a second sound within 500 ms gives a false pair. Ramps closer than 500 ms merge (so the ambiguity guard, which fires on neighbours closer than twice the pairing window, cannot fire at the default 200 ms
|
||||
|
|
|
|||
|
|
@ -254,8 +254,9 @@ export function syncAnalyze({ audio, sampleRate, audioStartS = 0, visual, visual
|
|||
// A video resampled to constant frame rate by `fps` snaps each frame to the nearest source frame: half a period more slack on each side.
|
||||
const hopMs = a.resolutionMs, periodMs = Math.max(v.framePeriodMs, visualGapMs), win = pairWindowMs / 1000, snapMs = visualResampled ? periodMs / 2 : 0;
|
||||
const classify = (lo, hi, ramp) => {
|
||||
// A ramp's start cannot be bounded below by looking at it (a slow start is under the noise), so a ramp is only ever shown late, never early or inside the window.
|
||||
if (ramp) return lo > prof.lagMs ? "audio-late-detectable" : "borderline";
|
||||
// A ramp is never given a gate-failing verdict. Two Soul passes falsified every claim a ramp could make: its start cannot be bounded below (a slow start sits under the noise),
|
||||
// and any upper bound read from the raw frames is moved earlier by one outlier frame, and the pairing by a bed that swells near the hit. The intervals are printed as estimates.
|
||||
if (ramp) return "borderline";
|
||||
if (lo >= -prof.leadMs && hi <= prof.lagMs) return "inside-window";
|
||||
if (lo > prof.lagMs) return "audio-late-detectable";
|
||||
if (hi < -prof.leadMs) return "audio-early-detectable";
|
||||
|
|
|
|||
|
|
@ -242,11 +242,11 @@ t("ramp: the interval is wide and says so (a ramp has no first frame); it is jud
|
|||
const fx = rampFixture({ shape: "smoothstep", rampS: 0.45, fps: 60, offsetMs: 0 }), r = syncAnalyze({ audio: fx.audio, sampleRate: fx.sampleRate, visual: fx.visual, visualShape: "ramp", events: fx.events });
|
||||
for (const p of r.pairs) { assert.ok(p.lagHighMs - p.lagLowMs > 100, `interval ${p.lagHighMs - p.lagLowMs} ms`); assert.equal(p.verdict, "borderline"); }
|
||||
const late = rampFixture({ shape: "linear", rampS: 0.3, fps: 60, offsetMs: 400 }), rl = syncAnalyze({ audio: late.audio, sampleRate: late.sampleRate, visual: late.visual, visualShape: "ramp", pairWindowMs: 450, events: late.events });
|
||||
assert.ok(rl.pairs.every((p) => p.verdict === "audio-late-detectable"), "audio 400 ms after the picture starts to move is outside whatever the ramp's shape");
|
||||
assert.ok(rl.pairs.every((p) => p.verdict === "borderline" && p.lagMs > 300), "a ramp 400 ms ahead of the sound is measured but never given a verdict that fails the gate");
|
||||
});
|
||||
// A ramp verdict may be silent but not wrong. Soul found (a) a centred 60 ms average crosses before a fast picture does, so 'late' was claimed at true lags inside the window,
|
||||
// and (b) slow-start shapes begin far before they look like they do, so 'early' or 'inside' was claimed at true lags of 0 to 40 ms. Truth is known in every case.
|
||||
t("ramp: a fast rise or a step is not called detectably late when the sound is inside the window", () => {
|
||||
t("ramp: a fast rise or a step is never called detectably late", () => {
|
||||
for (const [rampS, off] of [[0.04, 98], [0.04, 60], [0.001, 60], [0.08, 90]]) for (const fps of [30, 60]) {
|
||||
const fx = rampFixture({ shape: "linear", rampS, fps, offsetMs: off, events: [0.5042, 1.9117, 3.2209, 4.6033, 5.9161, 7.2087, 8.5] });
|
||||
const r = syncAnalyze({ audio: fx.audio, sampleRate: fx.sampleRate, visual: fx.visual, visualShape: "ramp", events: fx.events });
|
||||
|
|
@ -261,19 +261,25 @@ t("ramp: a variable-frame-rate track does not stretch the smoothing or the bound
|
|||
assert.ok(r.pairs.length >= 5);
|
||||
for (const p of r.pairs) assert.ok(p.verdict !== "audio-late-detectable", `[${p.lagLowMs}, ${p.lagHighMs}] verdict ${p.verdict} at true lag 40`);
|
||||
});
|
||||
t("ramp: sweep of 120 shapes, rises (40-800 ms), decays, frame rates, noise and offsets: a ramp verdict is never wrong", () => {
|
||||
t("ramp: sweep of 120 shapes, rises (40-800 ms), decays, frame rates, noise and offsets: a ramp is never given a claim", () => {
|
||||
let s = 19; const rand = () => { s = (Math.imul(s, 1664525) + 1013904223) >>> 0; return s / 2 ** 32; }, pick = (a) => a[Math.floor(rand() * a.length)];
|
||||
let claims = 0;
|
||||
for (let k = 0; k < 120; k++) {
|
||||
const shape = pick(Object.keys(SHAPES)), rampS = pick([0.04, 0.08, 0.15, 0.3, 0.5, 0.8]), fps = pick([24, 30, 60, 120]), off = pick([-80, -40, 0, 20, 40, 98, 130, 200]), decayS = pick([0.3, 0.8, 2]), noise = pick([0.001, 0.004, 0.01]);
|
||||
const fx = rampFixture({ shape, rampS, fps, offsetMs: off, decayS, noise, events: [0.5042, 2.1117, 3.7209, 5.3033, 6.9161, 8.5087] });
|
||||
const r = syncAnalyze({ audio: fx.audio, sampleRate: fx.sampleRate, visual: fx.visual, visualShape: "ramp", pairWindowMs: 250, allowUnpaired: true, events: fx.events });
|
||||
for (const p of r.pairs) {
|
||||
assert.ok(["borderline", "audio-late-detectable", "ambiguous-pairing", "no-visual-onset"].includes(p.verdict), `${shape}/${rampS}/${fps}fps/${off}: a ramp is never shown inside or early, got ${p.verdict} [${p.lagLowMs}, ${p.lagHighMs}]`);
|
||||
if (p.verdict === "audio-late-detectable") { claims++; assert.ok(off > PROFILES.default.lagMs, `${shape}/${rampS}/${fps}fps decay ${decayS} noise ${noise}: called late at true lag ${off}: [${p.lagLowMs}, ${p.lagHighMs}]`); }
|
||||
assert.ok(["borderline", "ambiguous-pairing", "no-visual-onset"].includes(p.verdict), `${shape}/${rampS}/${fps}fps/${off}: a ramp gets no gate-failing or inside verdict, got ${p.verdict} [${p.lagLowMs}, ${p.lagHighMs}]`);
|
||||
}
|
||||
}
|
||||
assert.ok(claims > 0, "the sweep contains lags the detector can call late");
|
||||
});
|
||||
// The two cases the second Soul pass broke (a raw outlier frame before the true start, and a bed that swells near a hit): the detector may be fooled, the verdict may not follow.
|
||||
t("ramp: one outlier frame before a hit, or a swelling bed near it, cannot produce a gate-failing verdict", () => {
|
||||
const fx = rampFixture({ shape: "linear", rampS: 0.02, fps: 60, offsetMs: 80 }), v = Float64Array.from(fx.visual.v), tt = fx.visual.t;
|
||||
for (const e of fx.events) { const i = Math.round((e.t - 0.2) * 60); v[i] += 0.07; } // one bright frame 200 ms before each hit
|
||||
const spiked = syncAnalyze({ audio: fx.audio, sampleRate: fx.sampleRate, visual: { t: tt, v }, visualShape: "ramp", events: fx.events, allowUnpaired: true });
|
||||
const bed = Float64Array.from(fx.visual.v, (x, i) => x + 0.2 * Math.max(0, Math.sin(2 * Math.PI * tt[i]))); // a 1 Hz swell under the hits
|
||||
const swelling = syncAnalyze({ audio: fx.audio, sampleRate: fx.sampleRate, visual: { t: tt, v: bed }, visualShape: "ramp", events: fx.events, allowUnpaired: true });
|
||||
for (const r of [spiked, swelling]) { assert.ok(r.pairs.length > 0); assert.ok(r.pairs.every((p) => !/detectable$/.test(p.verdict)), JSON.stringify(r.pairs.map((p) => p.verdict))); assert.equal(r.summary.outsideWindow, 0); }
|
||||
});
|
||||
t("ramp: noise, a steady drift and a lone step give no ramp onsets from noise or drift", () => {
|
||||
const nf = 600, tt = Float64Array.from({ length: nf }, (_, i) => i / 60); let s = 5; const rand = () => { s = (Math.imul(s, 1664525) + 1013904223) >>> 0; return s / 2 ** 32 - 0.5; };
|
||||
|
|
|
|||
Loading…
Reference in a new issue