music-video-gen/flow-state/index.html
Dejvino 14d1204e82 Make grain a treatment, tempo a governor, and params commit harder
Grain was in every video. It was added twice unconditionally — every scene
called sigGrain, and the grade added its own on top — so the only thing that
varied between two tracks was how much of it there was. That makes grain the
renderer's fingerprint rather than a decision about one video.

It is now described rather than dialled (look/grain.js): a mode (off /
constant / swell / sections / transient), a cell size in pixels, a refresh
rate in frames, a mask (uniform, shadows, highlights, edges, bands) and a
chroma amount. Roughly 45% of tracks get none at all. The non-constant modes
carry a per-frame envelope computed in Show._postAt from frame and features
only, so preview and export still agree. Scene-side grain is gated the same
way, and a module can decline it outright with `texture: 0` — crisp line work
should stay crisp. The post tab grew a real grain block so any of it can be
forced per track.

Slow songs got fast scenes. `motion` bias was mostly section energy with
tempo as a small correction, so a 70bpm track's drop asked for nearly as much
speed as a 150bpm one. Motion is now tempo-dominated, and every `rate: true`
param is additionally scaled by a per-track rateScale — measured, 84bpm now
samples its rate params at 0.276 of range against 148bpm's 0.571.

Parameter sampling also commits harder: extremity starts at 0.45 rather than
0.25 and shapes the draw more aggressively. This was first pushed to 0.82 and
backed off to 0.72, because the gates caught the overshoot — seeds began
collapsing onto the same range ends and a sparse scene sampled at its low end
rendered effectively black.

Fallout worth recording: turning the default grade grain off exposed two
scenes that were never really animating. Dust Chamber and Eclipse Field
passed the Phase 7 movement gate only because per-pixel noise was moving
underneath them; both now breathe on their own fixed clock, and Dust Chamber
needed a brightness floor as well. Four scenes (Classic Wave, Silk Ribbon,
Kaleido Tunnel, Slow Orb) express the style trait ONLY through grain and so
cannot opt out yet; they hold a reduced share at 0.35 pending real edge and
softness response.

Phase 3's look-space check now measures its closest pair relative to image
brightness, the same correction Phase 10 already documents for sparse scenes:
the absolute number was being propped up by grain rather than by look-space
width. Five new Phase 10 checks cover grain distribution, treatment variety,
envelope range, the texture opt-out, and tempo. 93/93 pass.

Two transport bugs, both stale state surfacing in the UI:

- Loading a track replaces audio.src, which stops playback silently, so
  state.playing stayed true and the play button stayed on pause — the first
  click after a track change only flipped the flag back. Added stopPlayback().
- The controls row wrapped mid-song because two readouts that change length
  while playing were sized by their content: the clock crossing ten minutes
  and the section label whenever a scene name is long or a crossfade appears.
  The clock is now fixed-width with tabular figures and the section label is
  the row's only flexible item, laying out at zero width and ellipsising into
  whatever space is left. The two spacers competed with it for that space and
  are gone; its own text-align does their job.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 07:04:27 +02:00

85 lines
3.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>flow-state</title>
<link rel="stylesheet" href="/src/ui/style.css">
</head>
<body>
<div id="app">
<div id="stage">
<canvas id="canvas"></canvas>
<div id="overlay">
<div id="dropzone">
<div class="dz-inner">
<div class="dz-title">flow-state</div>
<div class="dz-sub">drop an audio file, or click to choose</div>
<div class="dz-hint">mp3 · flac · wav · ogg</div>
</div>
</div>
</div>
<div id="hud" hidden></div>
</div>
<div id="transport">
<div id="timeline">
<canvas id="timeline-canvas"></canvas>
</div>
<div id="controls">
<button id="btn-play" title="Play / pause (space)"></button>
<button id="btn-prev-section" title="Previous section (←)"></button>
<button id="btn-next-section" title="Next section (→)"></button>
<button id="btn-loop" title="Loop current section (L)"></button>
<span id="time-display">0:00 / 0:00</span>
<!-- The section readout is the row's only flexible item: it
absorbs all the free space and centres its own text, which
is what the two spacers used to do. They competed with it
for that space and squeezed it to nothing. -->
<span id="section-display"></span>
<label class="ctl">quality
<select id="sel-quality">
<option value="draft">draft</option>
<option value="full" selected>full</option>
</select>
</label>
<button id="btn-reroll" title="New seed for the whole track">reroll</button>
<button id="btn-reroll-section" title="New scene for this section only">reroll section</button>
<button id="btn-lock" title="Lock this section against rerolls">lock</button>
<button id="btn-hud" title="Toggle debug HUD (D)">hud</button>
<button id="btn-osd" title="Toggle the title plate in the corner (O)">osd</button>
<button id="btn-segment" title="Render 20s around the playhead at export quality">test render</button>
<button id="btn-export" class="primary" title="Export the full video">export</button>
</div>
</div>
<aside id="panel">
<div id="track-header">
<div class="th-top-row">
<div class="th-info">
<span id="th-label" class="th-label">no track loaded</span>
<span id="th-name" class="th-name" hidden>no track</span>
</div>
<button id="btn-change-track" class="th-btn" title="Choose or drop an audio file">choose track</button>
</div>
<div id="th-progress" class="th-progress" hidden>
<div id="th-step" class="th-step">decoding…</div>
<div class="an-bar"><div id="th-fill" class="an-fill"></div></div>
</div>
</div>
<div id="panel-tabs">
<button data-tab="look" class="active">look</button>
<button data-tab="scene">scene</button>
<button data-tab="post">post</button>
<button data-tab="export">export</button>
</div>
<div id="panel-body"></div>
</aside>
</div>
<input type="file" id="file-input" accept="audio/*" hidden>
<audio id="audio" hidden></audio>
<script type="module" src="/src/main.js"></script>
</body>
</html>