@litfamily/litgravity 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +19 -3
  3. package/README_ko-KR.md +19 -3
  4. package/TRADEMARK.md +12 -0
  5. package/package.json +3 -2
  6. package/plugin/hooks/lib/lanes.mjs +65 -0
  7. package/plugin/hooks/lib/liveness.mjs +81 -0
  8. package/plugin/hooks/lib/motion.mjs +34 -5
  9. package/plugin/hooks/lib/reentry.mjs +7 -0
  10. package/plugin/hooks/lib/rewind/brief.mjs +364 -0
  11. package/plugin/hooks/lib/rewind/collect.mjs +359 -0
  12. package/plugin/hooks/lib/rewind/gauge.mjs +55 -0
  13. package/plugin/hooks/lib/rewind/next-step.mjs +77 -0
  14. package/plugin/hooks/lib/rewind/redact.mjs +60 -0
  15. package/plugin/hooks/lib/rewind/transcripts.mjs +214 -0
  16. package/plugin/hooks/lib/routes.mjs +79 -5
  17. package/plugin/hooks/lib/workflow-stack.mjs +213 -0
  18. package/plugin/hooks/post-tool-use.mjs +39 -1
  19. package/plugin/hooks/pre-invocation.mjs +93 -2
  20. package/plugin/hooks/session-start.mjs +26 -3
  21. package/plugin/hooks/stop.mjs +55 -6
  22. package/plugin/hud/looks.mjs +29 -0
  23. package/plugin/hud/render.mjs +277 -12
  24. package/plugin/plugin.json +1 -1
  25. package/plugin/skills/frontend-ui-ux/SKILL.md +12 -1
  26. package/plugin/skills/frontend-ui-ux/kit/components.css +417 -0
  27. package/plugin/skills/frontend-ui-ux/kit/fonts.json +22 -0
  28. package/plugin/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
  29. package/plugin/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
  30. package/plugin/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
  31. package/plugin/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
  32. package/plugin/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
  33. package/plugin/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
  34. package/plugin/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
  35. package/plugin/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
  36. package/plugin/skills/frontend-ui-ux/kit/ui.js +226 -0
  37. package/plugin/skills/frontend-ui-ux/references/house-styles.md +234 -0
  38. package/plugin/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
  39. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +196 -0
  40. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +30 -9
  41. package/plugin/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +20 -8
  42. package/plugin/skills/frontend-ui-ux/scripts/interface-probe.mjs +42 -9
  43. package/plugin/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
  44. package/plugin/skills/lit-adhd/SKILL.md +160 -0
  45. package/plugin/skills/lit-adhd/references/card-examples.md +107 -0
  46. package/plugin/skills/lit-adhd/references/status-taxonomy.md +34 -0
  47. package/plugin/skills/lit-adhd/scripts/rewind.mjs +5 -0
  48. package/plugin/skills/lit-diagram-drawer/SKILL.md +5 -3
  49. package/plugin/skills/lit-diagram-drawer/references/drawing-rules.md +1 -1
  50. package/plugin/skills/lit-diagram-drawer/references/style-guide.md +21 -12
  51. package/plugin/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
  52. package/plugin/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
  53. package/plugin/skills/lit-diagram-drawer/references/type-tree.md +3 -3
  54. package/plugin/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
  55. package/plugin/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +1 -2
  56. package/plugin/skills/lit-diagram-drawer/scripts/visual-quality.mjs +1 -2
  57. package/plugin/skills/lit-docx/SKILL.md +3 -3
  58. package/plugin/skills/lit-handoff/SKILL.md +1 -0
  59. package/plugin/skills/lit-hijack/SKILL.md +263 -0
  60. package/plugin/skills/lit-hijack/references/capture-and-provenance.md +100 -0
  61. package/plugin/skills/lit-hijack/references/clean-room-build.md +75 -0
  62. package/plugin/skills/lit-hijack/references/distil-and-licence.md +67 -0
  63. package/plugin/skills/lit-hijack/references/gap-and-port-design.md +100 -0
  64. package/plugin/skills/lit-hijack/references/parity-and-report.md +85 -0
  65. package/plugin/skills/lit-hijack/scripts/hijack.mjs +953 -0
  66. package/plugin/skills/lit-plan/SKILL.md +3 -2
  67. package/plugin/skills/lit-plan/references/plan-contract.md +12 -1
  68. package/plugin/skills/lit-plan/scripts/check-plan.mjs +39 -3
  69. package/plugin/skills/lit-plan/templates/plan.md +3 -0
  70. package/plugin/skills/lit-pptx/SKILL.md +8 -8
  71. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
  72. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
  73. package/plugin/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
  74. package/plugin/skills/lit-pptx/fonts/provenance.json +32 -1
  75. package/plugin/skills/lit-pptx/references/agents/analyst.md +34 -56
  76. package/plugin/skills/lit-pptx/references/agents/antithesis.md +49 -67
  77. package/plugin/skills/lit-pptx/references/agents/architect.md +38 -51
  78. package/plugin/skills/lit-pptx/references/agents/critic.md +25 -41
  79. package/plugin/skills/lit-pptx/references/agents/synthesizer.md +37 -46
  80. package/plugin/skills/lit-pptx/references/agents/thesis.md +29 -49
  81. package/plugin/skills/lit-pptx/references/anti-slop-checklist.md +119 -145
  82. package/plugin/skills/lit-pptx/references/authoring-guide.md +187 -278
  83. package/plugin/skills/lit-pptx/references/consensus-protocol.md +99 -97
  84. package/plugin/skills/lit-pptx/references/data-display-cookbook.md +36 -137
  85. package/plugin/skills/lit-pptx/references/density-and-fill.md +147 -216
  86. package/plugin/skills/lit-pptx/references/design-system-azure.md +56 -85
  87. package/plugin/skills/lit-pptx/references/direction-step.md +134 -176
  88. package/plugin/skills/lit-pptx/references/examples/01-pitch-signal-ko.md +114 -115
  89. package/plugin/skills/lit-pptx/references/examples/02-pitch-studio-ko.md +66 -66
  90. package/plugin/skills/lit-pptx/references/examples/03-business-review-ledger-ko.md +63 -63
  91. package/plugin/skills/lit-pptx/references/examples/04-business-review-night-en.md +96 -96
  92. package/plugin/skills/lit-pptx/references/examples/05-research-talk-paper-en.md +81 -81
  93. package/plugin/skills/lit-pptx/references/examples/06-lecture-chalk-ko.md +103 -103
  94. package/plugin/skills/lit-pptx/references/examples/07-data-review-night-en.md +100 -98
  95. package/plugin/skills/lit-pptx/references/examples/08-image-led-atlas-ko.md +76 -76
  96. package/plugin/skills/lit-pptx/references/examples/09-briefing-gazette-ko.md +96 -96
  97. package/plugin/skills/lit-pptx/references/examples/10-status-update-ledger-ko.md +80 -80
  98. package/plugin/skills/lit-pptx/references/examples/11-portfolio-studio-en.md +72 -72
  99. package/plugin/skills/lit-pptx/references/examples/12-research-tutorial-chalk-en.md +95 -95
  100. package/plugin/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +173 -0
  101. package/plugin/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +154 -0
  102. package/plugin/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +139 -0
  103. package/plugin/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +158 -0
  104. package/plugin/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +179 -0
  105. package/plugin/skills/lit-pptx/references/interview-protocol.md +83 -102
  106. package/plugin/skills/lit-pptx/references/layout-families.md +161 -265
  107. package/plugin/skills/lit-pptx/references/stages/autopilot.md +30 -70
  108. package/plugin/skills/lit-pptx/references/stages/interview.md +36 -68
  109. package/plugin/skills/lit-pptx/references/stages/plan.md +26 -67
  110. package/plugin/skills/lit-pptx/references/title-treatments.md +93 -145
  111. package/plugin/skills/lit-pptx/references/tonalities/atlas.md +95 -108
  112. package/plugin/skills/lit-pptx/references/tonalities/bauhaus.md +140 -0
  113. package/plugin/skills/lit-pptx/references/tonalities/chalk.md +107 -122
  114. package/plugin/skills/lit-pptx/references/tonalities/computational-brutalism.md +150 -0
  115. package/plugin/skills/lit-pptx/references/tonalities/gazette.md +87 -111
  116. package/plugin/skills/lit-pptx/references/tonalities/ledger.md +96 -125
  117. package/plugin/skills/lit-pptx/references/tonalities/neo-brutalism.md +161 -0
  118. package/plugin/skills/lit-pptx/references/tonalities/newsroom.md +144 -0
  119. package/plugin/skills/lit-pptx/references/tonalities/night.md +104 -131
  120. package/plugin/skills/lit-pptx/references/tonalities/paper.md +114 -130
  121. package/plugin/skills/lit-pptx/references/tonalities/riso.md +137 -0
  122. package/plugin/skills/lit-pptx/references/tonalities/signal.md +96 -103
  123. package/plugin/skills/lit-pptx/references/tonalities/studio.md +81 -112
  124. package/plugin/skills/lit-pptx/scripts/compile-deck.js +4 -6
  125. package/plugin/skills/lit-pptx/scripts/craft_extras.py +135 -91
  126. package/plugin/skills/lit-pptx/scripts/deck_craft.py +1 -1
  127. package/plugin/skills/lit-pptx/scripts/embed_fonts.py +13 -1
  128. package/plugin/skills/lit-pptx/scripts/layout_inventory.py +1 -1
  129. package/plugin/skills/lit-pptx/scripts/learn_template.py +1 -1
  130. package/plugin/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
  131. package/plugin/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
  132. package/plugin/skills/lit-pptx/scripts/lib/render-pack.js +370 -563
  133. package/plugin/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
  134. package/plugin/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
  135. package/plugin/skills/lit-pptx/scripts/qa_deck.py +6 -6
  136. package/plugin/skills/lit-pptx/scripts/render_pages.py +31 -0
  137. package/plugin/skills/lit-pptx/scripts/validate_pptx.py +1 -1
  138. package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v1.md +167 -191
  139. package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v2.md +117 -166
  140. package/plugin/skills/lit-pptx/specs/template-enrollment-contract.md +307 -330
  141. package/plugin/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
  142. package/plugin/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
  143. package/plugin/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
  144. package/plugin/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +99 -0
  145. package/plugin/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
  146. package/plugin/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
  147. package/plugin/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
  148. package/plugin/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
  149. package/plugin/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
  150. package/plugin/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
  151. package/plugin/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
  152. package/plugin/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
  153. package/plugin/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
  154. package/plugin/skills/lit-schematic/SKILL.md +114 -0
  155. package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
  156. package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
  157. package/plugin/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
  158. package/plugin/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
  159. package/plugin/skills/lit-schematic/references/cutaway-outputs.md +70 -0
  160. package/plugin/skills/lit-schematic/references/isometric-craft.md +101 -0
  161. package/plugin/skills/lit-schematic/references/journal-figures.md +72 -0
  162. package/plugin/skills/lit-schematic/references/kit-api.md +134 -0
  163. package/plugin/skills/lit-schematic/references/pfd-and-layout.md +53 -0
  164. package/plugin/skills/lit-schematic/references/pid-drafting.md +103 -0
  165. package/plugin/skills/lit-schematic/references/pid-symbols.md +163 -0
  166. package/plugin/skills/lit-schematic/references/verification.md +100 -0
  167. package/plugin/skills/lit-schematic/scripts/doctor.mjs +57 -0
  168. package/plugin/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
  169. package/plugin/skills/lit-schematic/scripts/lib/fonts.mjs +27 -0
  170. package/plugin/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
  171. package/plugin/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
  172. package/plugin/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
  173. package/plugin/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
  174. package/plugin/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
  175. package/plugin/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
  176. package/plugin/skills/lit-schematic/scripts/lib/png.mjs +132 -0
  177. package/plugin/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
  178. package/plugin/skills/lit-schematic/scripts/lib/route.mjs +218 -0
  179. package/plugin/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
  180. package/plugin/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
  181. package/plugin/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
  182. package/plugin/skills/lit-schematic/scripts/motion.mjs +129 -0
  183. package/plugin/skills/lit-schematic/scripts/qa.mjs +92 -0
  184. package/plugin/skills/lit-schematic/scripts/render.mjs +233 -0
  185. package/plugin/skills/lit-schematic/scripts/scaffold.mjs +60 -0
  186. package/plugin/skills/lit-scientific-visualization/SKILL.md +17 -6
  187. package/plugin/skills/lit-typographic-motion/SKILL.md +58 -48
  188. package/plugin/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +13 -2
  189. package/plugin/skills/lit-typographic-motion/engine/blender/runner.py +218 -0
  190. package/plugin/skills/lit-typographic-motion/engine/core/presets.mjs +1 -1
  191. package/plugin/skills/lit-typographic-motion/engine/node/analysis.mjs +65 -1
  192. package/plugin/skills/lit-typographic-motion/engine/node/assets.mjs +298 -0
  193. package/plugin/skills/lit-typographic-motion/engine/node/blender.mjs +143 -0
  194. package/plugin/skills/lit-typographic-motion/engine/node/board.mjs +136 -0
  195. package/plugin/skills/lit-typographic-motion/engine/node/brief.mjs +7 -1
  196. package/plugin/skills/lit-typographic-motion/engine/node/chrome.mjs +9 -12
  197. package/plugin/skills/lit-typographic-motion/engine/node/cover-assets.mjs +5 -3
  198. package/plugin/skills/lit-typographic-motion/engine/node/cover-capture.mjs +7 -6
  199. package/plugin/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +37 -4
  200. package/plugin/skills/lit-typographic-motion/engine/node/cover.mjs +19 -8
  201. package/plugin/skills/lit-typographic-motion/engine/node/done.mjs +45 -6
  202. package/plugin/skills/lit-typographic-motion/engine/node/frame-worker.mjs +7 -5
  203. package/plugin/skills/lit-typographic-motion/engine/node/gallery.mjs +121 -0
  204. package/plugin/skills/lit-typographic-motion/engine/node/host.mjs +34 -0
  205. package/plugin/skills/lit-typographic-motion/engine/node/house.mjs +44 -0
  206. package/plugin/skills/lit-typographic-motion/engine/node/look.mjs +34 -20
  207. package/plugin/skills/lit-typographic-motion/engine/node/pipeline.mjs +19 -9
  208. package/plugin/skills/lit-typographic-motion/engine/node/scaffold.mjs +210 -0
  209. package/plugin/skills/lit-typographic-motion/engine/node/score.mjs +639 -0
  210. package/plugin/skills/lit-typographic-motion/engine/node/sound-cli.mjs +21 -4
  211. package/plugin/skills/lit-typographic-motion/engine/node/sound.mjs +127 -29
  212. package/plugin/skills/lit-typographic-motion/engine/node/stage-capture.mjs +7 -6
  213. package/plugin/skills/lit-typographic-motion/engine/node/stage-gate.mjs +59 -5
  214. package/plugin/skills/lit-typographic-motion/engine/node/stage-qa.mjs +141 -9
  215. package/plugin/skills/lit-typographic-motion/engine/node/stage-serve.mjs +28 -5
  216. package/plugin/skills/lit-typographic-motion/engine/node/stage.mjs +82 -14
  217. package/plugin/skills/lit-typographic-motion/engine/node/styles.mjs +213 -0
  218. package/plugin/skills/lit-typographic-motion/engine/node/treatment.mjs +311 -10
  219. package/plugin/skills/lit-typographic-motion/engine/stage/cover-init.js +14 -2
  220. package/plugin/skills/lit-typographic-motion/engine/stage/init.js +11 -1
  221. package/plugin/skills/lit-typographic-motion/engine/stage/qa.js +6 -1
  222. package/plugin/skills/lit-typographic-motion/engine/stage/stage-kit.js +83 -0
  223. package/plugin/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
  224. package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
  225. package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
  226. package/plugin/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
  227. package/plugin/skills/lit-typographic-motion/recipes/hero-3d/expected.json +69 -0
  228. package/plugin/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
  229. package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +6 -4
  230. package/plugin/skills/lit-typographic-motion/recipes/painted-light/expected.json +4 -2
  231. package/plugin/skills/lit-typographic-motion/recipes/weight-tide/expected.json +7 -5
  232. package/plugin/skills/lit-typographic-motion/references/cover.md +394 -443
  233. package/plugin/skills/lit-typographic-motion/references/craft-loop.md +57 -87
  234. package/plugin/skills/lit-typographic-motion/references/depth.md +122 -0
  235. package/plugin/skills/lit-typographic-motion/references/look.md +94 -129
  236. package/plugin/skills/lit-typographic-motion/references/runtime.md +58 -91
  237. package/plugin/skills/lit-typographic-motion/references/sound.md +130 -99
  238. package/plugin/skills/lit-typographic-motion/references/stage.md +190 -215
  239. package/plugin/skills/lit-typographic-motion/references/studio.md +245 -0
  240. package/plugin/skills/lit-typographic-motion/references/style-bibles.md +108 -97
  241. package/plugin/skills/lit-typographic-motion/references/treatment.md +191 -143
  242. package/plugin/skills/lit-typographic-motion/scripts/motion-doctor.mjs +17 -5
  243. package/plugin/skills/lit-typographic-motion/scripts/motion.mjs +47 -7
  244. package/plugin/skills/lit-typographic-motion/styles/paper.json +41 -0
  245. package/plugin/skills/lit-typographic-motion/styles/swiss-signal.json +41 -0
  246. package/plugin/skills/lit-typographic-motion/styles/terminalcore.json +42 -0
  247. package/plugin/skills/lit-typographic-motion/styles/tidal.json +41 -0
  248. package/plugin/skills/litresearch/SKILL.md +1 -0
  249. package/plugin/skills/readme-studio/SKILL.md +2 -0
  250. package/plugin/skills/review-work/SKILL.md +1 -1
  251. package/plugin/skills/start-work/SKILL.md +2 -2
@@ -1,12 +1,14 @@
1
- // `motion.mjs sound --out <dir>`: build the generated bed from <dir>/treatment.json so it can be
2
- // heard and its cues checked before the full render. The render rebuilds the same bed at the film's
3
- // exact frame count and cut times, so the muxed track always matches the picture.
1
+ // `motion.mjs sound --out <dir>`: build the film's score (or a minimal film's generated bed) from
2
+ // <dir>/treatment.json so it can be heard and its cues checked before the full render. The render
3
+ // rebuilds the same track at the film's exact frame count and cut times, so the muxed track always
4
+ // matches the picture.
4
5
  import { existsSync } from "node:fs";
5
6
  import path from "node:path";
6
7
  import { EXIT } from "../core/constants.mjs";
7
8
  import { loadBrief, planFromBrief } from "./brief.mjs";
8
9
  import { BlockedError } from "./chrome.mjs";
9
10
  import { asBlocked } from "./pipeline.mjs";
11
+ import { writeScore } from "./score.mjs";
10
12
  import { prepareTrack, writeBed } from "./sound.mjs";
11
13
  import { loadTreatment } from "./treatment.mjs";
12
14
 
@@ -21,8 +23,19 @@ export function soundTimeline(out, treatment) {
21
23
  return { fps, frameCount: Math.round(treatment.durationSec * fps), cutTimes: treatment.beats.slice(1).map((b) => b.t0) };
22
24
  }
23
25
 
26
+ const scoreLabel = (score) => `score, ${score.genre} in ${score.key}, ${score.tempo} BPM, ${score.stems.filter((x) => x.kind !== "return").length} stems`;
27
+
24
28
  export async function soundCommand({ out }) {
25
29
  const treatment = asBlocked(() => loadTreatment(out));
30
+ if (treatment.sound.mode === "score") {
31
+ const { fps, frameCount, cutTimes } = soundTimeline(out, treatment);
32
+ const score = writeScore({ treatment, frameCount, fps, cutTimes, dir: out });
33
+ const sections = score.sections.map((x) => x.kind).join(" → ");
34
+ return {
35
+ code: EXIT.OK,
36
+ message: `SOUND: ${scoreLabel(score)} (${score.progression}; ${sections}; sidechain ${score.sidechainDb.toFixed(1)} dB; ${score.lufs.toFixed(1)} LUFS, peak ${score.peakDbfs.toFixed(1)} dBFS) in ${score.file}; stems in ${path.join(out, "sound", "stems")}; ${score.cues.length} cues in ${path.join(out, "sound-cues.json")}`,
37
+ };
38
+ }
26
39
  if (treatment.sound.mode !== "generated") {
27
40
  return { code: EXIT.OK, message: `SOUND: mode ${treatment.sound.mode}; nothing to generate (the render ${treatment.sound.mode === "none" ? "adds no track" : "prepares and muxes the track"})` };
28
41
  }
@@ -35,13 +48,17 @@ export async function soundCommand({ out }) {
35
48
  }
36
49
 
37
50
  /**
38
- * The film's track on either path: the generated bed at the film's exact frame count and cuts, a
51
+ * The film's track on either path: the score or the generated bed at the film's exact frame count and cuts, a
39
52
  * supplied or authored track padded or trimmed to the film, or none. Always muxed whatever the
40
53
  * audio-analysis tier's state (the Wave 1 renderer dropped a track when that tier was absent).
41
54
  */
42
55
  export function soundTrackFor({ treatment, out, stageDir = null, frameCount, fps, cutTimes, ffmpeg }) {
43
56
  const mode = treatment.sound.mode;
44
57
  if (mode === "none") return { mode, file: null, label: "none (asked for)" };
58
+ if (mode === "score") {
59
+ const score = writeScore({ treatment, frameCount, fps, cutTimes, dir: out });
60
+ return { mode, file: score.file, label: scoreLabel(score), bed: score };
61
+ }
45
62
  if (mode === "generated") {
46
63
  const bed = writeBed({ treatment, frameCount, fps, cutTimes, dir: out });
47
64
  return { mode, file: path.join(out, "sound", "bed.wav"), label: `generated bed, ${bed.timbre} in ${bed.key}, ${bed.tempo} BPM`, bed };
@@ -11,7 +11,6 @@ import { spawnSync } from "node:child_process";
11
11
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
12
12
  import path from "node:path";
13
13
  import { fnv1a32, mulberry32 } from "../core/util.mjs";
14
- import { describeSpawn } from "../../../../lib/host-exec.mjs";
15
14
 
16
15
  export const SOUND = Object.freeze({
17
16
  sampleRate: 48000,
@@ -29,6 +28,7 @@ export const SOUND = Object.freeze({
29
28
  fadeSec: 0.05,
30
29
  });
31
30
 
31
+ export { TABLE as WAVETABLE_SIZE };
32
32
  export const TEMPO_RANGE = Object.freeze([60, 160]);
33
33
  const PITCH = { C: 0, "C#": 1, Db: 1, D: 2, "D#": 3, Eb: 3, E: 4, F: 5, "F#": 6, Gb: 6, G: 7, "G#": 8, Ab: 8, A: 9, "A#": 10, Bb: 10, B: 11 };
34
34
  export const KEYS = Object.freeze({ pitchClasses: Object.freeze(Object.keys(PITCH)), modes: Object.freeze(["major", "minor"]) });
@@ -87,6 +87,13 @@ export function normalizePalette(palette) {
87
87
  return { timbre, key, mode, tempo };
88
88
  }
89
89
 
90
+ /**
91
+ * Sounds an on-screen event can make (treatment `sound.events`): a tap (a small click with a pitched
92
+ * body: a key, a latch, a drop landing), a hit (the cut hit), a whoosh (air ending on the event) and a
93
+ * chime (two notes of the key: something completes).
94
+ */
95
+ export const EVENT_SOUNDS = Object.freeze(["tap", "hit", "whoosh", "chime"]);
96
+
90
97
  const CUE_WORDS = [
91
98
  ["hit", /\b(?:hits?|impacts?|cuts?|stabs?|accents?)\b|타격|히트|컷|강세/iu],
92
99
  ["rise", /\b(?:rises?|rising|risers?|swells?|swelling|builds?|building|build-?ups?|lifts?|lifting)\b|상승|고조|빌드업/iu],
@@ -105,8 +112,11 @@ const nearest = (times, t, within) => {
105
112
  return best;
106
113
  };
107
114
 
108
- /** Accent cues, each measured against the beat boundary or cut it serves. */
109
- export function planCues({ beats = [], durationSec, cutTimes = [] }) {
115
+ /**
116
+ * Accent cues, each measured against the beat boundary or cut it serves, plus one `event` cue per
117
+ * on-screen event at its own time (it never snaps to a cut: it follows the picture).
118
+ */
119
+ export function planCues({ beats = [], durationSec, cutTimes = [], events = [] }) {
110
120
  const cues = [];
111
121
  const clampT = (t) => Math.min(durationSec, Math.max(0, t));
112
122
  beats.forEach((beat, beatIndex) => {
@@ -128,6 +138,12 @@ export function planCues({ beats = [], durationSec, cutTimes = [] }) {
128
138
  }
129
139
  }
130
140
  });
141
+ for (const e of Array.isArray(events) ? events : []) {
142
+ if (!EVENT_SOUNDS.includes(e?.kind) || !(e.t >= 0 && e.t < durationSec)) continue;
143
+ const beatIndex = Math.max(0, beats.findIndex((b) => e.t >= Number(b.t0) && e.t < Number(b.t1)));
144
+ const cut = nearest(cutTimes, e.t, Infinity);
145
+ cues.push({ kind: "event", sound: e.kind, t: round4(e.t), beatIndex, target: round4(e.t), delta: 0, on: String(e.on ?? ""), fromCut: cut === null ? null : round4(Math.abs(e.t - cut)) });
146
+ }
131
147
  cues.sort((a, b) => a.t - b.t || a.beatIndex - b.beatIndex);
132
148
  return cues;
133
149
  }
@@ -265,7 +281,8 @@ export function decodeWav(buffer) {
265
281
 
266
282
  // ---- synthesis ----
267
283
  const TABLE = 4096;
268
- function wavetable(harmonics) {
284
+ /** A normalized single-cycle table of additive partials (TABLE + 1 samples, wrapped). */
285
+ export function wavetable(harmonics) {
269
286
  const t = new Float32Array(TABLE + 1);
270
287
  let peak = 0;
271
288
  for (let i = 0; i < TABLE; i++) {
@@ -317,7 +334,7 @@ export function buildBed({ treatment, frameCount, fps, cutTimes = [] }) {
317
334
  const sampleCount = Math.round((frameCount * sr) / fps);
318
335
  const durationSec = sampleCount / sr;
319
336
  const beats = Array.isArray(treatment?.beats) ? treatment.beats : [];
320
- const cues = planCues({ beats, durationSec, cutTimes });
337
+ const cues = planCues({ beats, durationSec, cutTimes, events: treatment?.sound?.events });
321
338
  const rand = mulberry32(fnv1a32(`${treatment?.request ?? ""}|${palette.timbre}|${palette.key}|${palette.mode}|${palette.tempo}`));
322
339
  const L = new Float64Array(sampleCount);
323
340
  const R = new Float64Array(sampleCount);
@@ -446,22 +463,58 @@ export function buildBed({ treatment, frameCount, fps, cutTimes = [] }) {
446
463
  }
447
464
  }
448
465
  };
449
- for (const cue of cues) {
450
- if (cue.kind === "hit") {
451
- const s0 = Math.round(cue.t * sr);
452
- const len = Math.min(sampleCount - s0, Math.round(0.6 * sr));
466
+ // An on-screen event: a sound shaped like what the picture does at that frame.
467
+ const eventSound = (cue) => {
468
+ const s0 = Math.round(cue.t * sr);
469
+ if (cue.sound === "tap") {
470
+ const len = Math.min(sampleCount - s0, Math.round(0.3 * sr));
471
+ const hz = midiHz(tonic + 24 + (palette.mode === "major" ? 7 : 3));
453
472
  let f = 0;
454
- const c = onePole(voice.accent.kind === "bell" ? 6000 : 1800, sr);
455
- let ph = 0;
473
+ const c = onePole(4500, sr);
456
474
  for (let i = 0; i < len; i++) {
457
475
  const t = i / sr;
458
476
  f += c * (rand() * 2 - 1 - f);
459
- ph += (2 * Math.PI * (50 + 90 * Math.exp(-t / 0.02))) / sr;
460
- const v = 0.55 * Math.exp(-t / 0.12) * f + 0.5 * Math.exp(-t / 0.22) * Math.sin(ph);
477
+ const v = 1.2 * Math.exp(-t / 0.008) * f + 0.6 * Math.exp(-t / 0.07) * Math.sin(2 * Math.PI * hz * t);
461
478
  L[s0 + i] += v;
462
- R[s0 + i] += v;
479
+ R[s0 + i] += v * 0.9;
480
+ }
481
+ } else if (cue.sound === "whoosh") {
482
+ const start = Math.max(0, s0 - Math.round(0.4 * sr));
483
+ const tail = Math.min(sampleCount, s0 + Math.round(0.08 * sr));
484
+ let f = 0;
485
+ for (let s = start; s < tail; s++) {
486
+ const u = s < s0 ? (s - start) / Math.max(1, s0 - start) : 1 - (s - s0) / Math.max(1, tail - s0);
487
+ f += onePole(300 + 3200 * u, sr) * (rand() * 2 - 1 - f);
488
+ const v = 0.5 * u * u * f;
489
+ L[s] += v * (1 - 0.4 * u);
490
+ R[s] += v * (0.6 + 0.4 * u);
463
491
  }
464
- if (voice.accent.kind === "bell") strike(cue.t, [tonic + 12], 0.6, 0.12);
492
+ } else if (cue.sound === "chime") {
493
+ strike(cue.t, [tonic + 12], 1.2, 0.09);
494
+ strike(cue.t + 0.09, [tonic + 19], 1.2, 0.08);
495
+ } else {
496
+ hitAt(cue.t);
497
+ }
498
+ };
499
+ const hitAt = (t0) => {
500
+ const s0 = Math.round(t0 * sr);
501
+ const len = Math.min(sampleCount - s0, Math.round(0.6 * sr));
502
+ let f = 0;
503
+ const c = onePole(voice.accent.kind === "bell" ? 6000 : 1800, sr);
504
+ let ph = 0;
505
+ for (let i = 0; i < len; i++) {
506
+ const t = i / sr;
507
+ f += c * (rand() * 2 - 1 - f);
508
+ ph += (2 * Math.PI * (50 + 90 * Math.exp(-t / 0.02))) / sr;
509
+ const v = 0.55 * Math.exp(-t / 0.12) * f + 0.5 * Math.exp(-t / 0.22) * Math.sin(ph);
510
+ L[s0 + i] += v;
511
+ R[s0 + i] += v;
512
+ }
513
+ if (voice.accent.kind === "bell") strike(t0, [tonic + 12], 0.6, 0.12);
514
+ };
515
+ for (const cue of cues) {
516
+ if (cue.kind === "hit") {
517
+ hitAt(cue.t);
465
518
  } else if (cue.kind === "rise") {
466
519
  const s0 = Math.round(cue.start * sr);
467
520
  const s1 = Math.min(sampleCount, Math.round(cue.t * sr));
@@ -476,6 +529,8 @@ export function buildBed({ treatment, frameCount, fps, cutTimes = [] }) {
476
529
  L[s] += v * (1 - 0.3 * u);
477
530
  R[s] += v * (0.7 + 0.3 * u);
478
531
  }
532
+ } else if (cue.kind === "event") {
533
+ eventSound(cue);
479
534
  } else {
480
535
  const third = palette.mode === "major" ? 4 : 3;
481
536
  strike(cue.t, [tonic - 12, tonic, tonic + third, tonic + 7], voice.accent.decay, 0.1);
@@ -490,20 +545,61 @@ export function buildBed({ treatment, frameCount, fps, cutTimes = [] }) {
490
545
  R[sampleCount - 1 - i] *= g;
491
546
  }
492
547
 
493
- // Loudness to -16 LUFS through a soft limiter under -2 dBFS; quantized as the WAV will be.
548
+ const { left, right, lufs } = masterTo(L, R);
549
+ return { left, right, sampleCount, palette, cues, lufs: +lufs.toFixed(2), peakDbfs: +samplePeakDbfs([left, right]).toFixed(2), loudnessMethod: "BS.1770-4" };
550
+ }
551
+
552
+ /**
553
+ * The master stage every built track ends in: loudness to -16 LUFS through a lookahead limiter under
554
+ * -2 dBFS, quantized as the WAV will be. Returns the channels, the gain applied and the loudness.
555
+ *
556
+ * The limiter turns the gain down smoothly before a peak (5 ms lookahead, both channels linked, 80 ms
557
+ * release) instead of bending the waveform. A waveshaper adds harmonics the AAC encode turns into
558
+ * overshoot: one film's score sat at -2.1 dBFS in the WAV and decoded at +0.4 dBFS from the mux.
559
+ */
560
+ export function masterTo(L, R) {
561
+ const sampleCount = L.length;
494
562
  const ceiling = 10 ** (-2.1 / 20);
495
- const knee = 0.5 * ceiling;
496
- const limit = (x) => {
497
- const a = Math.abs(x);
498
- return a <= knee ? x : Math.sign(x) * (knee + (ceiling - knee) * Math.tanh((a - knee) / (ceiling - knee)));
499
- };
563
+ const ahead = Math.round(0.005 * SOUND.sampleRate);
564
+ const release = 1 - Math.exp(-1 / (0.08 * SOUND.sampleRate));
500
565
  const q = (v) => Math.round(Math.max(-1, Math.min(1, v)) * 32767) / 32767;
501
566
  const render = (gain) => {
567
+ // need[s]: the gain that keeps sample s under the ceiling; held[s]: the lowest need in the next
568
+ // `ahead` samples (a monotonic deque); then the release lets it rise slowly; then a moving average
569
+ // over `ahead` samples reaches every held value before its peak, so the result never exceeds need.
570
+ const need = new Float32Array(sampleCount);
571
+ for (let s = 0; s < sampleCount; s++) {
572
+ const a = Math.max(Math.abs(L[s]), Math.abs(R[s])) * gain;
573
+ need[s] = a > ceiling ? ceiling / a : 1;
574
+ }
575
+ const held = new Float32Array(sampleCount);
576
+ const deque = new Int32Array(sampleCount + ahead + 1);
577
+ let head = 0;
578
+ let tail = 0;
579
+ let next = 0;
580
+ for (let s = 0; s < sampleCount; s++) {
581
+ for (; next < Math.min(sampleCount, s + ahead + 1); next++) {
582
+ while (tail > head && need[deque[tail - 1]] >= need[next]) tail--;
583
+ deque[tail++] = next;
584
+ }
585
+ while (deque[head] < s) head++;
586
+ held[s] = need[deque[head]];
587
+ }
588
+ let env = 1;
589
+ const smooth = new Float32Array(sampleCount);
590
+ for (let s = 0; s < sampleCount; s++) {
591
+ env = Math.min(held[s], env + (1 - env) * release);
592
+ smooth[s] = env;
593
+ }
502
594
  const l = new Float32Array(sampleCount);
503
595
  const r = new Float32Array(sampleCount);
596
+ // The averaging window starts full of unity gain; the hard ceiling below catches the first 5 ms.
597
+ let win = ahead;
504
598
  for (let s = 0; s < sampleCount; s++) {
505
- l[s] = q(limit(L[s] * gain));
506
- r[s] = q(limit(R[s] * gain));
599
+ win += smooth[s] - (s >= ahead ? smooth[s - ahead] : 1);
600
+ const g = win / ahead;
601
+ l[s] = q(Math.max(-ceiling, Math.min(ceiling, L[s] * gain * g)));
602
+ r[s] = q(Math.max(-ceiling, Math.min(ceiling, R[s] * gain * g)));
507
603
  }
508
604
  return [l, r];
509
605
  };
@@ -516,7 +612,7 @@ export function buildBed({ treatment, frameCount, fps, cutTimes = [] }) {
516
612
  [left, right] = render(gain);
517
613
  lufs = integratedLoudness([left, right]);
518
614
  }
519
- return { left, right, sampleCount, palette, cues, lufs: +lufs.toFixed(2), peakDbfs: +samplePeakDbfs([left, right]).toFixed(2), loudnessMethod: "BS.1770-4" };
615
+ return { left, right, gain, lufs };
520
616
  }
521
617
 
522
618
  export function writeBed({ treatment, frameCount, fps, cutTimes = [], dir }) {
@@ -560,7 +656,7 @@ export function prepareTrack({ ffmpeg, input, frameCount, fps, dir, name = "trac
560
656
  const r = spawnSync(ffmpeg, ["-y", "-hide_banner", "-loglevel", "error", "-i", input, "-vn", "-ac", "2", "-ar", String(sr), "-c:a", "pcm_s16le", "-f", "wav", tmp], { encoding: "utf8" });
561
657
  if (r.status !== 0 || !existsSync(tmp)) {
562
658
  rmSync(tmp, { force: true });
563
- throw new SoundError("sound.file", `audio file could not be decoded (${describeSpawn(r)})`);
659
+ throw new SoundError("sound.file", `audio file could not be decoded: ${(r.stderr || r.error?.message || "").trim().split("\n").pop()}`);
564
660
  }
565
661
  let src;
566
662
  try {
@@ -622,6 +718,8 @@ export function auditMuxed({ ffmpeg, ffprobe = null, film, videoDurationSec, mod
622
718
  const peak = samplePeakDbfs(channels);
623
719
  const head = rmsRuns(channels);
624
720
  const lufs = integratedLoudness(channels);
721
+ // A generated bed and a score are built here to the loudness target; a supplied track is only reported.
722
+ const built = mode === "generated" || mode === "score";
625
723
  const rules = [{ id: "SOUND-STREAM", status: "PASS", detail: `audio stream present (${mode})` }];
626
724
  const dd = Math.abs(duration - videoDurationSec);
627
725
  rules.push({ id: "SOUND-DURATION", status: dd <= SOUND.durationToleranceSec ? "PASS" : "FAIL", detail: `audio ${duration.toFixed(3)} s vs video ${Number(videoDurationSec).toFixed(3)} s (limit ±${SOUND.durationToleranceSec} s)` });
@@ -629,14 +727,14 @@ export function auditMuxed({ ffmpeg, ffprobe = null, film, videoDurationSec, mod
629
727
  const headBad = head > SOUND.silenceMaxSec;
630
728
  rules.push({
631
729
  id: "SOUND-HEAD",
632
- status: headBad ? (mode === "generated" ? "FAIL" : "WARN") : "PASS",
730
+ status: headBad ? (built ? "FAIL" : "WARN") : "PASS",
633
731
  detail: `longest run below ${SOUND.silenceDbfs} dBFS RMS in the first ${SOUND.silenceHeadSec} s: ${head.toFixed(2)} s (limit ${SOUND.silenceMaxSec} s)`,
634
732
  });
635
733
  const inRange = Number.isFinite(lufs) && Math.abs(lufs - SOUND.targetLufs) <= SOUND.lufsTolerance;
636
734
  rules.push({
637
735
  id: "SOUND-LOUDNESS",
638
- status: mode === "generated" ? (inRange ? "PASS" : "WARN") : "PASS",
639
- detail: `integrated ${Number.isFinite(lufs) ? lufs.toFixed(2) : "-inf"} LUFS (BS.1770-4${mode === "generated" ? `, target ${SOUND.targetLufs} ± ${SOUND.lufsTolerance}` : ", reported"})`,
736
+ status: built ? (inRange ? "PASS" : "WARN") : "PASS",
737
+ detail: `integrated ${Number.isFinite(lufs) ? lufs.toFixed(2) : "-inf"} LUFS (BS.1770-4${built ? `, target ${SOUND.targetLufs} ± ${SOUND.lufsTolerance}` : ", reported"})`,
640
738
  });
641
- return { rules, exitCode: headBad && mode === "generated" ? 20 : null };
739
+ return { rules, exitCode: headBad && built ? 20 : null };
642
740
  }
@@ -1,4 +1,4 @@
1
- // One stage browser: headless Chrome on the software rung with the stage flag set, the page served
1
+ // One stage browser: headless Chrome on the round's rung (software, or GPU for a 3D film) with the stage flag set, the page served
2
2
  // by Fetch interception on http://lit.stage, the virtual-clock init script injected before any page
3
3
  // script, and a step/capture pair the renderer calls frame by frame. The master, the determinism
4
4
  // replay and the text-QA replay each open their own StageBrowser; none of them ever seeks.
@@ -16,12 +16,12 @@ const withTimeout = (promise, ms, message) => Promise.race([
16
16
  ]);
17
17
 
18
18
  export class StageBrowser {
19
- static async open({ stageDir, faces, rasters = [], width, height, seed, profileDir, env = process.env, log = () => {} }) {
19
+ static async open({ stageDir, faces, style = null, rasters = [], width, height, seed, profileDir, rung = "software", env = process.env, log = () => {} }) {
20
20
  const chrome = findChrome(env);
21
21
  if (!chrome) throw new BlockedError(EXIT.BLOCKED_NO_CHROME, "BLOCKED_NO_CHROME: Chrome/Chromium not found (set CHROME_PATH or install Google Chrome)");
22
- const flags = stageFlags({ width, height });
22
+ const flags = stageFlags({ width, height, rung });
23
23
  const session = await ChromeSession.launch({ chrome, flags, profileDir, routes: () => null });
24
- const browser = new StageBrowser(session, { stageDir, faces, width, height, flags, log });
24
+ const browser = new StageBrowser(session, { stageDir, faces, style, width, height, flags, rung, log });
25
25
  try {
26
26
  await browser.#attach(seed);
27
27
  await browser.#load(rasters);
@@ -32,14 +32,15 @@ export class StageBrowser {
32
32
  return browser;
33
33
  }
34
34
 
35
- constructor(session, { stageDir, faces, width, height, flags, log }) {
35
+ constructor(session, { stageDir, faces, style = null, width, height, flags, rung, log }) {
36
36
  this.session = session;
37
+ this.rung = rung;
37
38
  this.width = width;
38
39
  this.height = height;
39
40
  this.flags = flags;
40
41
  this.faces = faces;
41
42
  this.log = log;
42
- this.router = stageRouter({ stageDir, faces });
43
+ this.router = stageRouter({ stageDir, faces, style });
43
44
  this.served = [];
44
45
  }
45
46
 
@@ -7,7 +7,7 @@ import { auditRecords } from "../core/flash.mjs";
7
7
 
8
8
  const r = (id, status, detail, extra = {}) => ({ id, status, detail, ...extra });
9
9
 
10
- export const STAGE_GATE = Object.freeze({ durationTolerance: 0.1, nearBlackHoldSec: 2.4, nearBlackEdgeSec: 1 });
10
+ export const STAGE_GATE = Object.freeze({ durationTolerance: 0.1, nearBlackHoldSec: 2.4, nearBlackEdgeSec: 1, flatSpread: 0.02, flatHoldSec: 1, flatEdgeSec: 1, deadBusy: 0.025, deadHoldSec: 0.5, deadOpenSec: 0.4, deadCloseSec: 0.6 });
11
11
 
12
12
  function flash({ masterFlash, previewFlash, fps }) {
13
13
  const master = auditRecords(masterFlash, fps, { loop: false });
@@ -73,9 +73,62 @@ function nearBlack({ frames, fps }) {
73
73
  : r("MO-D-03", "PASS", "no empty near-black run longer than 2.4 s");
74
74
  }
75
75
 
76
- function webgl({ usesWebGL, renderer }) {
76
+ // An empty frame of any colour: almost every pixel within 0.02 of one luminance (0.5-99.5 %). A
77
+ // cream or white frame with nothing on it is as empty as a black one; MO-D-03 sees only black.
78
+ function flatFrames({ frames, fps }) {
79
+ if (!frames.length || frames.some((f) => typeof f.luminanceP005 !== "number")) return r("FLAT-FRAME", "N/A", "per-frame spread not recorded");
80
+ const flat = frames.map((f) => f.luminanceP995 - f.luminanceP005 < STAGE_GATE.flatSpread);
81
+ const limit = STAGE_GATE.flatHoldSec * fps;
82
+ const edge = STAGE_GATE.flatEdgeSec * fps;
83
+ let worst = null;
84
+ let start = -1;
85
+ for (let f = 0; f <= flat.length; f++) {
86
+ if (f < flat.length && flat[f]) {
87
+ if (start < 0) start = f;
88
+ continue;
89
+ }
90
+ if (start >= 0) {
91
+ const length = f - start;
92
+ const allowance = start === 0 || f === flat.length ? edge : 0;
93
+ if (length > limit + allowance && (!worst || length > worst.length)) worst = { length, from: start };
94
+ start = -1;
95
+ }
96
+ }
97
+ return worst
98
+ ? r("FLAT-FRAME", "FAIL", `${(worst.length / fps).toFixed(2)} s of empty frames from ${(worst.from / fps).toFixed(2)} s (nothing but one flat colour; limit ${STAGE_GATE.flatHoldSec} s)`)
99
+ : r("FLAT-FRAME", "PASS", `no run of empty frames longer than ${STAGE_GATE.flatHoldSec} s`);
100
+ }
101
+
102
+ // A near-empty frame: fewer than 2.5 % of its 48 px cells carry anything (one dot or one small object
103
+ // on the ground). Measured on round-1 films, a known dead frame sat at 1.1 % and drawn shots at 5 % and
104
+ // up. A run longer than 0.5 s fails; the opening may build from nothing for 0.4 s more, the close
105
+ // may fade for 0.6 s more.
106
+ function deadAir({ frames, fps }) {
107
+ if (!frames.length || frames.some((f) => typeof f.busy !== "number")) return r("DEAD-AIR", "N/A", "per-frame busy share not recorded");
108
+ const dead = frames.map((f) => f.busy < STAGE_GATE.deadBusy);
109
+ const limit = STAGE_GATE.deadHoldSec * fps;
110
+ let worst = null;
111
+ let start = -1;
112
+ for (let f = 0; f <= dead.length; f++) {
113
+ if (f < dead.length && dead[f]) {
114
+ if (start < 0) start = f;
115
+ continue;
116
+ }
117
+ if (start >= 0) {
118
+ const length = f - start;
119
+ const allowance = (start === 0 ? STAGE_GATE.deadOpenSec * fps : 0) + (f === dead.length ? STAGE_GATE.deadCloseSec * fps : 0);
120
+ if (length > limit + allowance && (!worst || length > worst.length)) worst = { length, from: start };
121
+ start = -1;
122
+ }
123
+ }
124
+ return worst
125
+ ? r("DEAD-AIR", "FAIL", `${(worst.length / fps).toFixed(2)} s of near-empty frames from ${(worst.from / fps).toFixed(2)} s (under ${STAGE_GATE.deadBusy * 100} % of the frame carries anything; limit ${STAGE_GATE.deadHoldSec} s)`)
126
+ : r("DEAD-AIR", "PASS", `no near-empty run longer than ${STAGE_GATE.deadHoldSec} s`);
127
+ }
128
+
129
+ function webgl({ usesWebGL, renderer, rung = "software" }) {
77
130
  if (!usesWebGL) return r("MO-C-02", "N/A", "the page draws no WebGL");
78
- return r("MO-C-02", "PASS", `WebGL on the software rung: ${renderer ?? "renderer unknown"} (labelled software)`);
131
+ return r("MO-C-02", "PASS", `WebGL on the ${rung} rung: ${renderer ?? "renderer unknown"}${rung === "software" ? " (labelled software)" : ""}`);
79
132
  }
80
133
 
81
134
  function determinism({ determinism: d }) {
@@ -93,7 +146,7 @@ function presence({ exports }) {
93
146
  /** Evaluate the stage gate. `extra` carries the sound and text-QA rules computed elsewhere. */
94
147
  export function evaluateStageGate(data) {
95
148
  const rules = [
96
- flash(data), ...floors(data), sizes(data), reducedMotion(data), nearBlack(data), webgl(data), determinism(data), presence(data),
149
+ flash(data), ...floors(data), sizes(data), reducedMotion(data), nearBlack(data), flatFrames(data), deadAir(data), webgl(data), determinism(data), presence(data),
97
150
  ...(data.extraRules ?? []),
98
151
  ];
99
152
  const failed = rules.filter((x) => x.status === "FAIL").map((x) => x.id);
@@ -106,7 +159,8 @@ export function formatStageReport({ gate, manifest, outputs, round, framesViewed
106
159
  "lit-typographic-motion — stage render report",
107
160
  `outputs: ${outputs.film} · ${outputs.preview} · ${outputs.poster} · ${outputs.still}${withheld ? " [WITHHELD: MO-C-03 flash audit failed; exports are diagnostics in withheld/, not deliverables]" : ""}`,
108
161
  `format / duration / fps: ${manifest.format} ${manifest.width}x${manifest.height}, ${manifest.durationSec} s (treatment ${manifest.treatmentDurationSec} s) @ ${manifest.fps} fps, ${manifest.frameCount} frames`,
109
- `renderer: ${manifest.renderer} (software rung, stage flags: ${manifest.chromeFlags.join(" ")})`,
162
+ `renderer: ${manifest.renderer} (${manifest.rung ?? "software"} rung, stage flags: ${manifest.chromeFlags.join(" ")})`,
163
+ ...(manifest.plate ? [`plate: Blender ${manifest.plate.blender}, ${manifest.plate.engine} ${manifest.plate.device}, ${manifest.plate.samples} spp, ${manifest.plate.frames} frames at ${manifest.plate.fps} fps`] : []),
110
164
  `sound: ${manifest.sound?.mode ?? "none"}${manifest.sound?.label ? ` (${manifest.sound.label})` : ""}`,
111
165
  "",
112
166
  `QA gate: ${gate.pass ? "PASS" : "FAIL"}`,