@opengamehq/cli 0.0.0-stage → 0.4.0

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 (74) hide show
  1. package/AGENTS.md +235 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +128 -2
  4. package/dist/cli.mjs +1415 -0
  5. package/dist/opengame-global.js +3 -0
  6. package/dist/opengame-global.js.LEGAL.txt +1 -0
  7. package/dist/preflight-worker.mjs +13 -0
  8. package/dist/runtime-builder.mjs +800 -0
  9. package/dist/runtime-catalog.json +1 -0
  10. package/dist/runtime-catalog.sha256 +1 -0
  11. package/dist/runtime-shells/runtime-shell.html +4 -0
  12. package/dist/runtime-shells/runtime-shell.js +91 -0
  13. package/dist/safe-fs.py +242 -0
  14. package/dist/skills/manifest.json +512 -0
  15. package/dist/skills/opengame-accessibility/SKILL.md +90 -0
  16. package/dist/skills/opengame-api/SKILL.md +85 -0
  17. package/dist/skills/opengame-assets/SKILL.md +124 -0
  18. package/dist/skills/opengame-assets/references/pipeline.md +97 -0
  19. package/dist/skills/opengame-audio/SKILL.md +154 -0
  20. package/dist/skills/opengame-audio/helpers/audio-chain.js +325 -0
  21. package/dist/skills/opengame-audio/references/mix-notes.md +82 -0
  22. package/dist/skills/opengame-capture/SKILL.md +108 -0
  23. package/dist/skills/opengame-capture/references/pipeline.md +82 -0
  24. package/dist/skills/opengame-capture/references/threejs.md +145 -0
  25. package/dist/skills/opengame-characters/SKILL.md +129 -0
  26. package/dist/skills/opengame-characters/references/integration.md +144 -0
  27. package/dist/skills/opengame-characters/references/player-og.md +160 -0
  28. package/dist/skills/opengame-cli/SKILL.md +118 -0
  29. package/dist/skills/opengame-deploy/SKILL.md +204 -0
  30. package/dist/skills/opengame-deploy/references/json-events.md +62 -0
  31. package/dist/skills/opengame-deploy/references/manifest.md +83 -0
  32. package/dist/skills/opengame-deploy/references/packaging.md +117 -0
  33. package/dist/skills/opengame-depth/SKILL.md +130 -0
  34. package/dist/skills/opengame-enemies/SKILL.md +103 -0
  35. package/dist/skills/opengame-enemies/references/threejs.md +134 -0
  36. package/dist/skills/opengame-front-end/SKILL.md +143 -0
  37. package/dist/skills/opengame-front-end/references/launch.md +50 -0
  38. package/dist/skills/opengame-front-end/references/menus.md +47 -0
  39. package/dist/skills/opengame-game-feel/SKILL.md +137 -0
  40. package/dist/skills/opengame-game-feel/helpers/spring.js +146 -0
  41. package/dist/skills/opengame-game-feel/references/feel-numbers.md +83 -0
  42. package/dist/skills/opengame-jam/SKILL.md +103 -0
  43. package/dist/skills/opengame-lighting/SKILL.md +94 -0
  44. package/dist/skills/opengame-lighting/helpers/light-pool.js +185 -0
  45. package/dist/skills/opengame-loading/SKILL.md +99 -0
  46. package/dist/skills/opengame-loading/references/threejs.md +116 -0
  47. package/dist/skills/opengame-look/SKILL.md +114 -0
  48. package/dist/skills/opengame-look/references/post-and-lens.md +66 -0
  49. package/dist/skills/opengame-mobile/SKILL.md +90 -0
  50. package/dist/skills/opengame-performance/SKILL.md +140 -0
  51. package/dist/skills/opengame-performance/references/measuring.md +72 -0
  52. package/dist/skills/opengame-production/SKILL.md +131 -0
  53. package/dist/skills/opengame-production/references/templates.md +63 -0
  54. package/dist/skills/opengame-quality-bar/SKILL.md +122 -0
  55. package/dist/skills/opengame-quality-bar/references/cheap-tells.md +36 -0
  56. package/dist/skills/opengame-quality-bar/references/review-prompt.md +27 -0
  57. package/dist/skills/opengame-router/SKILL.md +51 -0
  58. package/dist/skills/opengame-router/references/process.md +38 -0
  59. package/dist/skills/opengame-scene-audit/SKILL.md +123 -0
  60. package/dist/skills/opengame-scene-audit/helpers/scene-audit.js +599 -0
  61. package/dist/skills/opengame-sdk/SKILL.md +254 -0
  62. package/dist/skills/opengame-sdk/references/engines.md +93 -0
  63. package/dist/skills/opengame-sdk/references/frame.md +107 -0
  64. package/dist/skills/opengame-sdk/references/identity.md +112 -0
  65. package/dist/skills/opengame-sdk/references/leaderboards.md +83 -0
  66. package/dist/skills/opengame-stability/SKILL.md +84 -0
  67. package/dist/skills/opengame-verification/SKILL.md +136 -0
  68. package/dist/skills/opengame-verification/helpers/browser-evidence.mjs +74 -0
  69. package/dist/skills/opengame-weapons/SKILL.md +109 -0
  70. package/dist/skills/opengame-weapons/references/handling-numbers.md +72 -0
  71. package/dist/skills/opengame-weapons/references/threejs.md +169 -0
  72. package/dist/skills/opengame-world-physics/SKILL.md +114 -0
  73. package/dist/skills/opengame-world-physics/references/measured-failures.md +52 -0
  74. package/package.json +38 -4
@@ -0,0 +1,325 @@
1
+ /**
2
+ * A master chain, buses with separate volume and duck gains, and a voice pool that
3
+ * steals the quietest voice with a short fade. Copy this file into the game; it imports
4
+ * nothing and builds every node once.
5
+ *
6
+ * import { createMasterChain, createVoicePool, selfTest } from "./audio-chain.js";
7
+ * const ctx = new AudioContext();
8
+ * const chain = createMasterChain(ctx); // buses: sfx, music, ambience, voice, ui
9
+ * const voices = createVoicePool(chain, { max: 48 });
10
+ * voices.play(buffer, { bus: "sfx", gain: 0.8, priority: 1 });
11
+ * voices.play(hitConfirm, { bus: "ui", protect: true });
12
+ * chain.setVolume("music", 0.6); // the player's slider
13
+ * chain.duck("music", 6, 0.5); // under a voice line, after the lead
14
+ *
15
+ * The order matters and each stage has one job:
16
+ * master gain -> glue compressor -> make-up gain -> limiter -> soft clip -> output
17
+ * The glue compressor holds overlapping sounds together without pumping. Make-up gain
18
+ * sits BEFORE the limiter so the limiter's threshold is the real ceiling. A
19
+ * DynamicsCompressorNode is not a brickwall: its attack lets the first millisecond of a
20
+ * transient through, so a soft clip after it rounds what escapes. The clip here is
21
+ * unity below its knee, so quiet sounds pass unchanged.
22
+ *
23
+ * Reference configuration: World at War and Modern Claudefare's mix (glue -15 dB, 4:1,
24
+ * knee 14, 6 ms, 180 ms; limiter -1.2 dB, 20:1, 1 ms, 60 ms). Run `selfTest()` after
25
+ * editing; it plants each defect this file prevents and fails unless it is caught.
26
+ */
27
+
28
+ export const CHAIN_DEFAULTS = Object.freeze({
29
+ buses: ["sfx", "music", "ambience", "voice", "ui"],
30
+ glue: { threshold: -15, knee: 14, ratio: 4, attack: 0.006, release: 0.18 },
31
+ makeupDb: 1.94,
32
+ limiter: { threshold: -1.2, knee: 0, ratio: 20, attack: 0.001, release: 0.06 },
33
+ clip: { knee: 0.6, ceiling: 0.97 },
34
+ duck: { leadSeconds: 0.12, attackSeconds: 0.06, releaseSeconds: 0.35 },
35
+ });
36
+
37
+ export const dbToGain = (db) => Math.pow(10, db / 20);
38
+
39
+ /**
40
+ * Unity below `knee`, then a tanh shoulder that approaches `ceiling` and never passes
41
+ * it. Continuous in value and slope at the knee, so it adds no click of its own.
42
+ */
43
+ export function softClipCurve({ knee, ceiling } = CHAIN_DEFAULTS.clip, samples = 4097) {
44
+ const curve = new Float32Array(samples);
45
+ const span = ceiling - knee;
46
+ for (let i = 0; i < samples; i++) {
47
+ const x = (i / (samples - 1)) * 2 - 1;
48
+ const a = Math.abs(x);
49
+ const y = a <= knee ? a : knee + span * Math.tanh((a - knee) / span);
50
+ curve[i] = Math.sign(x) * y;
51
+ }
52
+ return curve;
53
+ }
54
+
55
+ function setAll(param, values) { for (const [key, value] of Object.entries(values)) param[key].value = value; }
56
+
57
+ export function createMasterChain(ctx, options = {}) {
58
+ const config = { ...CHAIN_DEFAULTS, ...options };
59
+ const master = ctx.createGain();
60
+ const glue = ctx.createDynamicsCompressor();
61
+ setAll(glue, config.glue);
62
+ const makeup = ctx.createGain();
63
+ makeup.gain.value = dbToGain(config.makeupDb);
64
+ const limiter = ctx.createDynamicsCompressor();
65
+ setAll(limiter, config.limiter);
66
+ const clip = ctx.createWaveShaper();
67
+ clip.curve = softClipCurve(config.clip);
68
+ clip.oversample = "4x";
69
+ master.connect(glue); glue.connect(makeup); makeup.connect(limiter); limiter.connect(clip); clip.connect(ctx.destination);
70
+
71
+ const buses = {}, ducks = {}, duckUntil = {};
72
+ for (const name of config.buses) {
73
+ const volume = ctx.createGain(), duck = ctx.createGain();
74
+ volume.connect(duck); duck.connect(master);
75
+ buses[name] = volume; ducks[name] = duck; duckUntil[name] = 0;
76
+ }
77
+ const bus = (name) => {
78
+ if (!Object.hasOwn(buses, name)) throw new Error(`no bus named ${name}`);
79
+ return buses[name];
80
+ };
81
+
82
+ return {
83
+ ctx, master, glue, makeup, limiter, clip, buses, ducks,
84
+ /** Where a source connects. Volume and ducking live on separate gains so they never fight. */
85
+ input: bus,
86
+ setVolume(name, value) { bus(name).gain.setTargetAtTime(Math.max(0, value), ctx.currentTime, 0.015); },
87
+ /**
88
+ * Lowers a bus by `db` for `seconds`, starting after `leadSeconds` so the sound that
89
+ * caused the duck is heard at full level first. Overlapping ducks keep the deepest.
90
+ */
91
+ duck(name, db, seconds, { leadSeconds = config.duck.leadSeconds, attackSeconds = config.duck.attackSeconds, releaseSeconds = config.duck.releaseSeconds } = {}) {
92
+ bus(name);
93
+ const gain = ducks[name].gain, now = ctx.currentTime;
94
+ const start = now + leadSeconds, low = dbToGain(-Math.abs(db));
95
+ const until = start + attackSeconds + seconds;
96
+ if (duckUntil[name] > now && gain.value < low && until <= duckUntil[name]) return; // a deeper duck already holds
97
+ gain.cancelScheduledValues(now);
98
+ gain.setValueAtTime(gain.value, now);
99
+ gain.setValueAtTime(gain.value, start);
100
+ gain.linearRampToValueAtTime(low, start + attackSeconds);
101
+ gain.setValueAtTime(low, until);
102
+ gain.linearRampToValueAtTime(1, until + releaseSeconds);
103
+ duckUntil[name] = until + releaseSeconds;
104
+ },
105
+ dispose() {
106
+ for (const node of [master, glue, makeup, limiter, clip, ...Object.values(buses), ...Object.values(ducks)]) node.disconnect();
107
+ },
108
+ };
109
+ }
110
+
111
+ /**
112
+ * A bounded pool of one-shot voices. When full, the quietest unprotected voice is
113
+ * faded over `stealFadeSeconds` and replaced; protected voices (hit confirmation,
114
+ * announcer, warnings) go last. Voices are reclaimed by the time they were scheduled to
115
+ * end, not by `onended`, because the event loop that delivers `onended` is the thing a
116
+ * busy game starves.
117
+ */
118
+ export function createVoicePool(chain, { max = 48, stealFadeSeconds = 0.006 } = {}) {
119
+ const ctx = chain.ctx;
120
+ const voices = new Set();
121
+ const stats = { played: 0, stolen: 0, refused: 0 };
122
+
123
+ function release(voice, at) {
124
+ voice.gain.gain.cancelScheduledValues(at);
125
+ voice.gain.gain.setValueAtTime(voice.gain.gain.value, at);
126
+ voice.gain.gain.linearRampToValueAtTime(0, at + stealFadeSeconds);
127
+ try { voice.source.stop(at + stealFadeSeconds); } catch { /* already stopped */ }
128
+ voice.until = at + stealFadeSeconds;
129
+ voice.released = true;
130
+ }
131
+ function reap(now) { for (const voice of voices) if (voice.until > 0 && voice.until <= now) { voices.delete(voice); voice.gain.disconnect(); } }
132
+ /** Loudness as heard: the voice's own gain times its bus volume, after its scheduled fades. */
133
+ const heard = (voice) => voice.gain.gain.value * chain.input(voice.bus).gain.value;
134
+
135
+ return {
136
+ stats,
137
+ get active() { return voices.size; },
138
+ play(buffer, { bus = "sfx", gain = 1, rate = 1, when = 0, priority = 0, protect = false } = {}) {
139
+ const now = ctx.currentTime;
140
+ reap(now);
141
+ const live = [...voices].filter((voice) => !voice.released);
142
+ let stoleNow = false;
143
+ if (live.length >= max) {
144
+ const candidates = live.filter((voice) => !voice.protect && (voice.priority <= priority || protect));
145
+ const pool = candidates.length ? candidates : protect ? live.filter((voice) => voice.priority <= priority) : [];
146
+ if (!pool.length) { stats.refused++; return null; }
147
+ const quietest = pool.reduce((a, b) => (heard(b) < heard(a) ? b : a));
148
+ release(quietest, now);
149
+ stats.stolen++;
150
+ stoleNow = true;
151
+ }
152
+ const source = ctx.createBufferSource();
153
+ source.buffer = buffer;
154
+ source.playbackRate.value = rate;
155
+ const amp = ctx.createGain();
156
+ amp.gain.value = gain;
157
+ source.connect(amp); amp.connect(chain.input(bus));
158
+ const start = Math.max(now, when);
159
+ const voice = { source, gain: amp, bus, priority, protect, released: false,
160
+ until: buffer && !source.loop ? start + buffer.duration / Math.max(rate, 1e-3) : 0 };
161
+ // The stolen voice fades first; the new one starts after it so the two never sum.
162
+ source.start(stoleNow ? Math.max(start, now + stealFadeSeconds) : start);
163
+ voices.add(voice);
164
+ stats.played++;
165
+ return { stop: () => release(voice, ctx.currentTime), voice };
166
+ },
167
+ stopAll() { const now = ctx.currentTime; for (const voice of voices) if (!voice.released) release(voice, now); },
168
+ };
169
+ }
170
+
171
+ /* ------------------------------------------------------------------------------------
172
+ * Self-test. A small recording stand-in for an AudioContext: it keeps the graph and the
173
+ * scheduled automation so the properties can be measured without a sound card. The same
174
+ * checks run against a real context's chain in a browser, because they only read what
175
+ * this file built.
176
+ * ---------------------------------------------------------------------------------- */
177
+
178
+ class FakeParam {
179
+ constructor(value) { this.value = value; this.events = []; }
180
+ setValueAtTime(v, t) { this.events.push({ type: "set", v, t }); if (t <= 0) this.value = v; return this; }
181
+ linearRampToValueAtTime(v, t) { this.events.push({ type: "ramp", v, t }); return this; }
182
+ setTargetAtTime(v) { this.value = v; return this; }
183
+ cancelScheduledValues(t) { this.events = this.events.filter((e) => e.t < t); return this; }
184
+ /** Evaluates set and linear-ramp automation at time t. */
185
+ at(t) {
186
+ let value = this.value, time = -Infinity;
187
+ for (const e of [...this.events].sort((a, b) => a.t - b.t)) {
188
+ if (e.t > t) { if (e.type === "ramp") return value + (e.v - value) * ((t - time) / (e.t - time)); break; }
189
+ value = e.v; time = e.t;
190
+ }
191
+ return value;
192
+ }
193
+ }
194
+ class FakeNode {
195
+ constructor(kind) { this.kind = kind; this.outputs = new Set(); }
196
+ connect(node) { this.outputs.add(node); return node; }
197
+ disconnect() { this.outputs.clear(); }
198
+ }
199
+ export function createFakeAudioContext() {
200
+ const ctx = { currentTime: 0, destination: new FakeNode("destination") };
201
+ ctx.createGain = () => Object.assign(new FakeNode("gain"), { gain: new FakeParam(1) });
202
+ ctx.createDynamicsCompressor = () => Object.assign(new FakeNode("compressor"), Object.fromEntries(["threshold", "knee", "ratio", "attack", "release"].map((k) => [k, new FakeParam(0)])));
203
+ ctx.createWaveShaper = () => Object.assign(new FakeNode("shaper"), { curve: null, oversample: "none" });
204
+ ctx.createBufferSource = () => Object.assign(new FakeNode("source"), { buffer: null, loop: false, playbackRate: new FakeParam(1), startedAt: null, stoppedAt: null,
205
+ start(t) { this.startedAt = t; }, stop(t) { this.stoppedAt = t; } });
206
+ return ctx;
207
+ }
208
+
209
+ /** Every route from `node` to the destination, as lists of nodes. */
210
+ function routes(node, destination, path = []) {
211
+ if (node === destination) return [[...path, node]];
212
+ if (path.includes(node)) return [];
213
+ return [...node.outputs].flatMap((next) => routes(next, destination, [...path, node]));
214
+ }
215
+
216
+ /**
217
+ * The properties a mix depends on, read from a built chain. Returns failures.
218
+ * `ctx` must be the context the chain was built on.
219
+ */
220
+ export function chainProperties(chain) {
221
+ const failures = [];
222
+ const { ctx } = chain;
223
+ for (const [name, input] of Object.entries(chain.buses)) {
224
+ const all = routes(input, ctx.destination);
225
+ if (!all.length) failures.push(`bus ${name} never reaches the output`);
226
+ for (const route of all) {
227
+ const li = route.indexOf(chain.limiter), ci = route.indexOf(chain.clip);
228
+ if (li < 0 || ci < 0 || ci < li) failures.push(`bus ${name} reaches the output without passing the limiter and then the soft clip`);
229
+ }
230
+ }
231
+ if (routes(chain.makeup, chain.limiter).length === 0) failures.push("make-up gain is not before the limiter, so the limiter threshold is not the ceiling");
232
+ const curve = chain.clip.curve;
233
+ if (!curve) failures.push("soft clip has no curve");
234
+ else {
235
+ let previous = -Infinity, peak = 0;
236
+ for (const y of curve) { if (y < previous - 1e-7) { failures.push("soft clip curve is not monotonic"); break; } previous = y; peak = Math.max(peak, Math.abs(y)); }
237
+ if (peak > 0.98) failures.push(`soft clip reaches ${peak.toFixed(3)}; it should stay below its ceiling`);
238
+ const quiet = Math.pow(10, -8 / 20), index = Math.round(((quiet + 1) / 2) * (curve.length - 1));
239
+ const x = (index / (curve.length - 1)) * 2 - 1, gainDb = 20 * Math.log10(curve[index] / x);
240
+ if (Math.abs(gainDb) > 0.1) failures.push(`soft clip changes a -8 dBFS signal by ${gainDb.toFixed(2)} dB; it should pass quiet sound unchanged`);
241
+ }
242
+ return failures;
243
+ }
244
+
245
+ /** True when a duck leaves the causing sound at full level until its lead has passed. */
246
+ export function duckHoldsLead(chain, bus = "music", leadSeconds = CHAIN_DEFAULTS.duck.leadSeconds) {
247
+ chain.ctx.currentTime = 10;
248
+ chain.duck(bus, 9, 0.5);
249
+ const param = chain.ducks[bus].gain;
250
+ return Math.abs(param.at(10 + leadSeconds * 0.8) - 1) < 1e-6 && param.at(10 + leadSeconds + 0.2) < 0.5;
251
+ }
252
+
253
+ /** Fills a six-voice pool, plays one more, and reports which voice was stolen and how. */
254
+ export function stealBehaviour(makePool, chain) {
255
+ const pool = makePool(chain);
256
+ const buffer = { duration: 2 };
257
+ chain.ctx.currentTime = 1;
258
+ const gains = [0.9, 0.2, 0.7, 0.05, 0.8, 0.6];
259
+ const handles = gains.map((gain, i) => pool.play(buffer, { bus: i === 3 ? "ui" : "sfx", gain, protect: i === 3 }));
260
+ pool.play(buffer, { bus: "sfx", gain: 1 });
261
+ const stolen = handles.filter((h) => h && h.voice.released).map((h) => h.voice);
262
+ const victim = stolen[0];
263
+ const now = chain.ctx.currentTime;
264
+ return {
265
+ count: stolen.length,
266
+ gain: victim ? victim.gain.gain.value : null,
267
+ protectedStolen: stolen.some((v) => v.protect),
268
+ fadeSeconds: victim ? (victim.source.stoppedAt ?? now) - now : null,
269
+ fadeEndsAtZero: victim ? victim.gain.gain.at(now + 0.0061) === 0 && victim.gain.gain.at(now + 0.003) > 0 : false,
270
+ };
271
+ }
272
+
273
+ /** What a player would hear wrong in a steal: the wrong voice, a protected one, or a click. */
274
+ export function stealFailures(steal) {
275
+ const failures = [];
276
+ if (steal.count !== 1) failures.push(`stealing released ${steal.count} voices for one new sound`);
277
+ if (steal.gain !== 0.2) failures.push(`stole a voice at gain ${steal.gain}; the quietest unprotected voice was 0.2`);
278
+ if (steal.protectedStolen) failures.push("stole a protected voice while unprotected ones were playing");
279
+ if (!(Math.abs(steal.fadeSeconds - 0.006) < 1e-9) || !steal.fadeEndsAtZero) failures.push("a stolen voice was not faded to zero over 6 ms before stopping");
280
+ return failures;
281
+ }
282
+
283
+ /** The pool most games start with: the oldest voice goes, with a hard stop. */
284
+ function plantedOldestPool(chain) {
285
+ const played = [];
286
+ return {
287
+ play(buffer, { bus = "sfx", gain = 1, protect = false } = {}) {
288
+ const now = chain.ctx.currentTime;
289
+ if (played.length >= 6) {
290
+ const first = played.shift();
291
+ first.voice.released = true;
292
+ first.voice.gain.gain.setValueAtTime(0, now);
293
+ first.voice.source.stop(now);
294
+ }
295
+ const source = chain.ctx.createBufferSource(), amp = chain.ctx.createGain();
296
+ amp.gain.value = gain; source.connect(amp); amp.connect(chain.input(bus)); source.start(now);
297
+ const handle = { voice: { source, gain: amp, protect, released: false } };
298
+ played.push(handle);
299
+ return handle;
300
+ },
301
+ };
302
+ }
303
+
304
+ export function selfTest() {
305
+ const failures = [];
306
+ const fresh = (options) => createMasterChain(createFakeAudioContext(), options);
307
+
308
+ // Planted: a bus wired straight to the output, around the limiter.
309
+ const bypass = fresh(); bypass.ducks.sfx.connect(bypass.ctx.destination);
310
+ if (!chainProperties(bypass).some((f) => f.includes("bus sfx"))) failures.push("planted bus bypass was not caught");
311
+ // Planted: a tanh curve scaled to its ceiling, which adds about 4.5 dB to quiet sound.
312
+ const loud = fresh(); const K = 1.6, norm = 0.97 / Math.tanh(K);
313
+ loud.clip.curve = Float32Array.from({ length: 4097 }, (_, i) => Math.tanh(((i / 4096) * 2 - 1) * K) * norm);
314
+ if (!chainProperties(loud).some((f) => f.includes("-8 dBFS"))) failures.push("planted gain-adding clip curve was not caught");
315
+ // Planted: a duck with no lead.
316
+ if (duckHoldsLead(fresh({ duck: { ...CHAIN_DEFAULTS.duck, leadSeconds: 0 } }))) failures.push("planted duck without a lead was not caught");
317
+ // Planted: the oldest voice stolen with a hard stop.
318
+ if (!stealFailures(stealBehaviour(plantedOldestPool, fresh())).length) failures.push("planted oldest-voice pool was not caught");
319
+
320
+ // The real chain.
321
+ failures.push(...chainProperties(fresh()));
322
+ if (!duckHoldsLead(fresh())) failures.push("duck lowers the bus before its lead has passed");
323
+ failures.push(...stealFailures(stealBehaviour((chain) => createVoicePool(chain, { max: 6 }), fresh())));
324
+ return { ok: failures.length === 0, examined: 7, failures };
325
+ }
@@ -0,0 +1,82 @@
1
+ # Mix notes
2
+
3
+ ## Why the helper's soft clip differs from AW's
4
+
5
+ AW's master chain ends in a WaveShaper with a tanh curve scaled to reach 0.97 at full
6
+ scale (`tanh(x * 1.6) * 0.97 / tanh(1.6)`). Its comment describes the curve as within
7
+ 0.1 dB of unity below -8 dBFS. Computed, the curve adds about 4.5 dB to quiet signals
8
+ (+4.52 dB at -30 dBFS, +3.45 dB at -8 dBFS) and only reaches unity near full scale,
9
+ because scaling a tanh to its ceiling also scales its slope at zero. Sitting after the
10
+ limiter, it lifts everything quiet and moves the true ceiling.
11
+
12
+ The helper's curve is exactly unity below a knee and a tanh shoulder above it that
13
+ approaches the ceiling without passing it, continuous in value and slope at the knee.
14
+ `chainProperties` checks a -8 dBFS signal passes within 0.1 dB, and the self-test plants
15
+ AW's curve to prove that check sees the difference. Measure any curve you write the same
16
+ way; a comment about a curve is a claim, not a measurement.
17
+
18
+ ## Sound families for a shooter
19
+
20
+ Plan the families from the whole game before production, not from the few actions in an
21
+ early blockout. For a shooter (ST's list):
22
+
23
+ - Weapons: report, body and tail; dry fire; equip and holster; magazine out, in and seat;
24
+ bolt, slide or pump; shell insert and eject; casings by surface.
25
+ - Movement: walk, run, land and jump by the terrain actually walked; ladders as rungs,
26
+ not one sound at the top (AW).
27
+ - Impacts and ricochets by material.
28
+ - Damage, shield and low health; enemy anticipation, action and reaction.
29
+ - Pickups, interaction, objectives; interface focus, confirm and back; results.
30
+ - Ambience per place: a quiet bed plus sparse local events, crossfaded between zones,
31
+ stopped on pause and restarted from the current state on resume, never as a backlog.
32
+ - Music states (menu, exploration, tension, combat, resolution) as tracks or layers with
33
+ deliberate transitions.
34
+
35
+ Other genres need the equivalent depth for their own mechanics. Do not invent weapons or
36
+ materials to reach a count.
37
+
38
+ ## Recorded or designed, never a placeholder
39
+
40
+ Our originals ban procedural sound entirely: no runtime oscillators, no synthesised
41
+ fallback, because a fallback that never fires in testing ships as the real sound on
42
+ somebody else's machine. A game whose style is synthesis can design synthesis on purpose;
43
+ what no game should ship is a beep standing in for a sound nobody made.
44
+
45
+ ## Generated sound
46
+
47
+ Write prompts like directions to a recordist: source and material, attack, body, tail,
48
+ distance, duration and whether it loops. Keep one acoustic space per family. Trim
49
+ unwanted silence before an attack, keep real tails, and remeasure after every edit. A
50
+ delayed gunshot or footstep is a failed cue when its visible contact already happened.
51
+ See `opengame-assets` for the generation services themselves.
52
+
53
+ ## Listening is a result of its own
54
+
55
+ A recording of the busiest moment, listened to at a consistent level, is a separate
56
+ result from every measurement. Peak and loudness readings, cue counts and a compressor
57
+ in the code do not establish that the game sounds good. Record listening, final-output
58
+ measurement and missing cues as separate lines in a report.
59
+
60
+ ## What OC's library cost
61
+
62
+ OC generated its sound with ElevenLabs. Rates as measured on 16 Oct: sound effects about
63
+ 11 credits a second, speech 0.43 credits a character, music 13.8 credits a second, at
64
+ $0.000183 a credit. The first library was 1,275 files for $11.70; ElevenLabs spend reached
65
+ $27.56 by 19 Oct against a $500 cap, and the shipped library was 2,895 files. Takes per cue
66
+ were 2 to 4, curated by measurement and then by ear.
67
+
68
+ Generated one-shots often peak late. Ask for "one single event that starts instantly at
69
+ 0 ms" and cut to the transient. Loop stems need a join with no lag: a loop cut on the beat
70
+ grid stuttered by 45-68 ms.
71
+
72
+ Log the spend before each paid call, and keep the generated files with the prompt that made
73
+ them, so a remake starts from the prompt instead of from memory.
74
+
75
+ ## Phones
76
+
77
+ OC's iPhone fixes, most important first, were these. Ship the build that carries audio on
78
+ that device (only the threaded build did). Resume the context on touch, visibility change and
79
+ interruption. Keep the player's weapon in the highest priority class so a busy horde cannot
80
+ take its voices. Never clamp output latency below the mixer's own lead, which garbled every
81
+ device. Test each fix on the phone itself. Emulation passed every build that was silent on the
82
+ real device.
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: opengame-capture
3
+ description: Make a browser game filmable and screenshot-testable. Covers a host-stepped clock, one time scale, seeded takes, a director camera whose cuts reset history, a clean feed with HUD masks and mute flags, an awaitable ready state, acknowledged capture requests, a state probe, stepped audio, 4K60 readback from the render surface and hooks kept out of public builds. Use when the person wants a trailer, gameplay footage, slow motion, a photo mode or screenshot tests, or says takes do not repeat.
4
+ metadata:
5
+ version: "1.0.0"
6
+ ---
7
+
8
+ # Capture: a game you can film and test
9
+
10
+ OC's launch film is 62 s of 4K60 from 43 shots, cut from 401 kept takes. The game had no
11
+ capture mode, so the film team added every hook to a forked build while filming: a stepped
12
+ clock, a free camera, HUD masks, mute flags, a probe. Each hook was small. Finding out it
13
+ was needed cost a reshoot, and about 24 of the 47 hours went to restarts and usage limits on
14
+ top. The owner's brief: "i do NOT want to have to keep watching shitty takes and giving u
15
+ feedbaxk thqt u should be able to know ill give u based on those skills".
16
+
17
+ Build these into the game before anyone films it. The same hooks make screenshot tests
18
+ repeatable, which is most of what `opengame-verification` asks of a capture.
19
+
20
+ Rules carry five tags; `opengame-quality-bar` explains them and the game codes. The
21
+ three.js way to do each is in [references/threejs.md](references/threejs.md); pipeline
22
+ numbers, the capability audit and process are in [references/pipeline.md](references/pipeline.md).
23
+
24
+ ## Rules
25
+
26
+ ### The host steps one clock
27
+ - **Invariant:** In capture mode the host advances the game by a fixed simulation step per output frame, every system reads that one clock, and no game code reads wall time.
28
+ - **Technique:** A capture mode where the host calls step, then render, then read back, and the game's own frame loop is off. Simulation, physics, animation, particles, weather, camera smoothing and audio all take their time from the step, and worker threads read the same clock. Slow motion is a smaller step, never frame interpolation. Gameplay never runs faster than real time; speed on screen comes from the camera.
29
+ - **Reference configuration:** OC's time came from `performance.now()` in a worker, and page-level tricks failed: a fake page clock froze timers and virtual time never reached the workers. A shim replaced `performance.now` and `requestAnimationFrame` in the worker and retried a frame when the GPU slot was busy; its first version took 48-64 min and the full rig about 2 h. Real-time 4K ran at 25-31 fps, so 1 s of 4K60 cost about 5.2 s of wall time. Stepped, the rig ran 28.1 fps first person and 37.2 fps on a dolly at 4K on an idle M4 Max, 2.1-3.5 s of wall time per output second. A step of 1/60 is 1x and 1/240 is 0.25x; 240 frames covered 1.000 s of simulation with 0 skipped. The montage reused the rig unchanged on a new build in about an hour.
30
+ - **Applies when:** Every game that will be filmed, screenshot-tested or compared frame by frame.
31
+ - **Verify:** Capture 240 frames at a 1/240 step: the probe's simulation time rises by exactly one step per frame and ends at 1 s. Repeat on a loaded machine and get the same frames.
32
+
33
+ ### One time scale, and every timer obeys it
34
+ - **Invariant:** Every timer in the game (hitstop, shake, camera lerps, particles, physics, corpse settling, emitters, flashes, audio) runs on scaled simulation time, so an effect at quarter speed looks like the same effect slowed down.
35
+ - **Technique:** One time scale applied where the clock is read, never per system. Replace frame-count timers with time. Physics sub-steps or interpolates so a small step does not hold a pose and then jump. Motion blur takes its shutter from the step. A cinematic flag turns off hitstop and kill-cam time dilation. Review every effect at quarter speed before filming.
36
+ - **Reference configuration:** OC: a 45 ms kill hitstop became about 9 near-frozen frames at 0.3x, and a 70 ms hammer hold about 12 frames at 0.25x. Corpses solved at a fixed 60 Hz, so at 0.25x a pose held for 4 frames, then jumped. A gib trail emitted every third frame, and per-frame emitters ran 4 times denser. A game-only time scale left particles on presentation time at full speed. Motion blur reached a 360-degree shutter at 1/240 until its strength was set to 60 times the step in seconds (0.25 at 1/240). At 0.25x a light re-firing every 0.09 s strobed at 10 Hz, a blood sprite covered about 40% of the frame, and a bloom clipped to white. The frozen-flip defect was predicted in an audit, still reached the owner about 28 h later, and cost about 3 h and reshoots for a 6-line fix.
37
+ - **Applies when:** Games with slow motion, hitstop, or any effect timed by frames.
38
+ - **Verify:** Render each effect at 1x and at 0.25x and lay the frames side by side: the slow version has four times the frames of the same motion, with no holds, jumps or denser particles.
39
+
40
+ ### One seed makes a take repeat
41
+ - **Invariant:** Two runs of the same take with the same seed, clock and scripted input produce the same frames.
42
+ - **Technique:** One global seed feeds every random source: weather, sky, lightning, voice picks, idle animation, spawns. Nothing seeds from wall time or the operating system in capture mode. A switch freezes ambient events. Script input against simulation frames, and record the seed in the take's spec.
43
+ - **Reference configuration:** OC: 0 of 240 frame signatures matched between two runs, because sky, lightning, boss idle and voice picks were seeded from wall time or OS randomness while camera and scripted input were exact. Workarounds: a voice seed set at least 2 s before the start under load, a forced lightning strike 3.3 s before a take to push the next one at least 14 s away, and 25 dev strikes to land the take's own strike on the boss's helm. Reshoots on a new build still kept identical kill frames (28 of 131), so the clock and scripted input were enough for reshoots.
44
+ - **Applies when:** Every game with randomness that will be filmed or screenshot-tested.
45
+ - **Verify:** Shoot the same take twice and hash every frame: all hashes match.
46
+
47
+ ### The director's camera wins, and a cut resets history
48
+ - **Invariant:** A director camera overrides gameplay and cutscene cameras whenever it is set, and a cut gives a clean first frame with no trace of the previous shot.
49
+ - **Technique:** A camera override layer with position, look target, field of view, roll and near plane, and a cut call that resets temporal anti-aliasing history, motion blur and auto exposure. Call the same reset when a visible mesh swaps. Cutscenes accept an external camera and keep the simulation running. Under a free camera, draw the third-person body and world weapon while aim stays with the player.
50
+ - **Reference configuration:** OC's engine had a camera cut that nothing in the game called, so a hard jump smeared the whole frame through TAA. Crate weapons cycling every 0.06-0.32 s ghosted until each gun was held for at least 4 frames with a cut on each swap. The victory cinematic took the camera, deleted the zombies and hid the body, and the hook that let the film own the ending took about 5.5 h. With the cut, a first-to-third-person hand-off on the fastest swing frame became the "best cut in the film". Over-the-shoulder shots of the player were impossible because the 0.7 m head filled the frame.
51
+ - **Applies when:** Games with temporal effects (TAA, motion blur, auto exposure) or scripted cameras.
52
+ - **Verify:** Cut between two distant cameras and inspect the first frame after: no ghost of the previous shot. Swap a held item and step through it frame by frame.
53
+
54
+ ### A clean feed, element by element
55
+ - **Invariant:** Each HUD element and each world-space gameplay marker can be hidden on its own, music and voice can each be muted, and a clean take keeps whatever feedback the shot asks for.
56
+ - **Technique:** A named flag for every interface element and world marker (hit markers, score pops, crosshair, plates, subtitles, set-piece UI, telegraphs, weak-point marks, rings) and a mask that picks which to draw. Tag world markers separately from art. One clean-feed switch sets the usual mask and mutes music and voice; prove the mute by loudness. Interface projected from the player's camera lines up only in first person, so hide it on other cameras. Dev overlays, page badges and cheat effects never reach the frame.
57
+ - **Reference configuration:** OC's owner asked to hide "the H UD except hitmarkers and like the points juice". A HUD mask (score pops, hit marker, crosshair, points plate) plus flags for subtitles and set-piece UI took about 3 min to build. The old hide flag also hid boss marks and the letterbox, subtitles ignored it, and the mask drew over it, so cinematics had to clear both. Cyan rings, a weak-point capsule, floor telegraphs, glyphs and strike circles read as HUD on film. On the montage, dev-funded score jumps from 1,039 to 49,550 showed on screen.
58
+ - **Applies when:** Every game with a HUD that will be filmed or used for marketing stills.
59
+ - **Verify:** A contact sheet of one frame with each flag on and off. On the clean feed, a reviewer marks every visible interface element; only the masked-in ones remain.
60
+
61
+ ### Ready means resident
62
+ - **Invariant:** The game exposes one state the capture script can await that means every model, texture, pipeline and sound the scene needs is resident and the quality setting is locked, and a load failure reports itself instead of crashing.
63
+ - **Technique:** Count pending loads, compiles and decodes; resolve a promise or post a message when they reach zero after the scene is built and quality is fixed. Give each asset class a named failure and a timeout. In the unrecorded preroll, grant and show every item the take uses once, so late loads happen off camera. Lock quality: no dynamic resolution or automatic tier in capture mode.
64
+ - **Reference configuration:** OC had no such state. Under load, 55 boot crashes paired with a renderer assert on a missing material; about 40 takes hit it and 5 of 7 attempts at one shot were lost. Boot waits grew from 180 to 420 s, and takes were capped at 2-3 min with 2-5 retries. Late guns drew black for about 10 s ("give every gun once before shooting"), and sound banks stayed silent for 11-20 s. The renderer started on Low and calibrated, so dynamic resolution popped lights until quality was fixed after the title; the rig waited for the log line "renderer quality: fixed at ultra".
65
+ - **Applies when:** Every game that streams assets or calibrates quality.
66
+ - **Verify:** Await the state on a throttled connection and capture the next frame: every model is present and lit at final quality, and the first shot is audible. Block one asset: the state reports which one failed.
67
+
68
+ ### Capture requests are addressed to frames and acknowledged one by one
69
+ - **Invariant:** Every screenshot request and director command names the simulation frame it applies to, and the game acknowledges each one with the frame it ran on, so the capture script never guesses when something happened.
70
+ - **Technique:** A request queue with an id and a target frame per request. The game runs it at that frame and replies with the id, the frame, the build id, the screen it was on and whether assets were loaded. The capture script sends the next request after the reply and treats a missing reply as a failure. Screenshots wait for the interface to settle. Document the limits: command size, deadlines, and what happens to a command sent before the scene exists.
71
+ - **Reference configuration:** OC: real-time stage commands 0.2 s apart landed in the same frame and were lost under load, so staging moved to an unrecorded preroll. A shutter command sent only on change swallowed the frame-0 command. Commands sent before the scene existed were dropped, a scripted run aborted 10 s after its last command, and a command buffer over about 7.9 KB crashed the engine on load. Frame-addressed injection landed 59 of 59 on the right frame. Checking that each capture shows the screen it claims is in `opengame-verification`.
72
+ - **Applies when:** Every game driven by a capture or test script.
73
+ - **Verify:** Send 100 screenshot requests in a burst: 100 replies arrive, each with its own frame and the expected screen. Kill the game mid-burst: the capture script fails the run.
74
+
75
+ ### A state probe in render space, checked on day one
76
+ - **Invariant:** On request or every frame, the game reports where the camera, the player, each enemy's head and joints, bosses and objective states are, taken from the same snapshot that was rendered and in render space, and the report matches the picture.
77
+ - **Technique:** A probe flag that emits one record per frame from post-skinning transforms in the rendered snapshot. Name items and tables in the record; never make anyone map indices by hand. On the first day, project probe points into a rendered frame and check each lands on the drawn head, joint or item. Export the per-frame camera and joints if CG will be composited.
78
+ - **Reference configuration:** OC built `probe=1`, one JSON line of 2-4 KB per frame, because log lines were the only channel from game to host. It was wrong in ways that cost shots: the head bone sat 0.17-0.2 m below the visible head; titan joints were 10-13 m off the rendered model and never fixed; a documented overlook camera was inside a wall; a gun table was off by one, so one gun's slot gave another and 6 shots hit with the wrong gun. The per-frame camera and joint export matched Blender to 0.0003 px. No depth or object-ID matte existed, so a 3D logo could avoid characters but not pass behind them.
79
+ - **Applies when:** Games where a capture script aims, frames or checks shots from game state.
80
+ - **Verify:** Draw probe points over 20 captured frames: each lands on its drawn feature within a few pixels.
81
+
82
+ ### Audio is captured at simulation rate, per bus
83
+ - **Invariant:** A take's sound comes from the simulation at the take's own rate, music, voice, effects and ambience are available as separate stems, and each bus can be muted from the launch URL.
84
+ - **Technique:** Mute and stem flags readable at launch. In capture mode, drain the mixer per output frame by exactly the samples one step covers, trim the output latency, and save a cue log with each cue's simulation time. Slow motion yields audio the length of simulated time, so the edit retimes or replaces it. Load every sound bank a take uses before recording.
85
+ - **Reference configuration:** OC: music and voice were baked into every take until music and voice mute flags existed, found when 12 of 22 voice lines overlapped. The rig drained `sampleRate * step` samples per frame and trimmed 4,095 samples (85 ms) of latency; 13 of 145 cues needed re-alignment in slow-motion takes. On the montage, settings-menu mute clicks never landed and all 9 segments were reshot (`opengame-audio` has the numbers). The film mastered at -13.8 LUFS and -1.6 dBTP against a -14 LUFS target.
86
+ - **Applies when:** Every game with sound that will be filmed.
87
+ - **Verify:** Capture the same shot at 1x and at 0.25x. At 1x each shot's sound lines up with its muzzle flash to within a frame. With music muted, the music stem measures silent.
88
+
89
+ ### Every frame comes from the render surface
90
+ - **Invariant:** Delivered footage holds every frame at the delivery resolution and frame rate, read from the render surface with correct colour tags, however loaded the machine is.
91
+ - **Technique:** After each stepped frame, read back the render surface, convert colour on the GPU to the encoder's format and tag it, and encode with a hardware encoder through WebCodecs. Page screenshots and screencasts are for stills and debugging, never for motion. Render at native resolution with a device pixel ratio of 1, lock the quality preset, and stop the run if the browser fell back to a software rasteriser. Check output by counting unique frames and measuring colour, never by frame count alone.
92
+ - **Reference configuration:** OC: `page.screenshot` at 4K took 2,516 ms; a CDP screencast gave 12-19 fps, lossy; CPU x264 encoded 1.7-4.2 fps at 1080p. A swapchain copy with `copyTextureToBuffer` and `mapAsync` took 30.4 ms at 4K. WebCodecs tagged frames BT.601, so a GPU pass to NV12 BT.709 fixed it (Y 68.7 dB against ffmpeg, against 41.3 dB for BT.601). HEVC at 300 Mbps banded least on the storm sky (H.264 at 160 Mbps flattened 51% of blocks, HEVC 14.5%); the 4K master is 2.25 GB per output minute. Supersampling at dpr 1.5 cost 3.4x (11.0 against 37.2 fps) for no visible gain. Dropped frames were 0 regardless of load, because frames were stepped, not timed. Frame-count QA passed a 3,720-frame cut whose frames 1-402 were frozen.
93
+ - **Applies when:** Every game filmed for a trailer, montage or store page.
94
+ - **Verify:** `ffprobe` reports the expected size, rate and BT.709 tags; the count of unique frames equals the count of frames; one frame matches a direct readback of the same step.
95
+
96
+ ### Capture hooks are off by default and absent from public builds
97
+ - **Invariant:** Capture hooks live in the shipping game's code, each off by default behind its own flag, change nothing while off, and are absent or locked in the public build.
98
+ - **Technique:** One flag per hook, listed in one file with what it does. A parity frame proves flags-off equals the release. Strip hooks at build time for the public build, or gate them behind a key whose secret is not in the bundle. Record the build hash and every flag a take used in the take's spec. Write each film fix as a flag the game can adopt.
99
+ - **Reference configuration:** OC added about 25-30 default-off hooks in a day, each diffable as a hooks list and a patch, versioned film builds by wasm hash with receipts, and proved parity with the release round on a frame. The fork had costs: the final film mixes selects from at least 5 builds and no single build reproduces it, and one take depended on environment variables nobody recorded. Production disabled dev URL switches with a dev key stored only as a SHA-256 hash. Film fixes flowed back: the film's lightning became the game default (flat-white share 10.47% to 0.58%).
100
+ - **Applies when:** Every game with capture or test hooks and a public build.
101
+ - **Verify:** Grep the public bundle for every hook name; open the public URL with each flag set and see no change; diff a flags-off frame from the capture build against the release.
102
+
103
+ ## Other engines
104
+
105
+ Unity sets a fixed capture step with `Time.captureDeltaTime`, and its Recorder package
106
+ writes stepped frames. Godot 4 renders offline with `--write-movie <file>` and
107
+ `--fixed-fps <n>` on the command line. Both still need the time scale, seed, camera and
108
+ clean-feed rules above; the engine steps the clock, and every timer in the game has to read it.
@@ -0,0 +1,82 @@
1
+ # Capture pipeline, audit and process
2
+
3
+ Numbers from OC's launch film (a 62 s 4K60 trailer) and its gameplay montage, filmed on an
4
+ M4 Max with 16 cores.
5
+
6
+ ## Audit before planning shots
7
+
8
+ Before writing a shot list, check each item against the build you will film, and write down
9
+ what is missing. OC's film team found most of these one at a time, mid-production.
10
+
11
+ - A frozen build to film, and how long a private rebuild takes.
12
+ - A command channel from the capture script into the game, and its size and deadline limits.
13
+ - A host-stepped clock, one time scale, and an audit of timers that read raw frame time or
14
+ count frames.
15
+ - A director camera with a cut.
16
+ - A HUD mask per element, world-marker flags and a clean-feed switch.
17
+ - Scripting for every actor in the shot, friendlies included: spawn, pose, equip by name,
18
+ emote, sit, fire. OC's friendlies could not be scripted at first, and a teleport despawned
19
+ the squad.
20
+ - A state probe, checked against a rendered frame.
21
+ - A quality lock, with flash settings at full strength (OC's Reduce Flashing has to stay
22
+ off for film, or every flash is cut to 20%).
23
+ - Readback, colour tags and the encoder.
24
+ - Audio mute flags and stems.
25
+ - Seeds and a freeze for ambient events.
26
+ - The boot crash rate under load.
27
+ - An animation audit on frames for every clip a shot needs: a contact sheet of 8 spaced and
28
+ 6 consecutive frames, root and head second-difference, foot slide.
29
+ - Hero poses and states that exist in play, not only in cutscenes, and world-state switches
30
+ such as time of day and weather. OC's dawn existed only on the results screen.
31
+ - Boot gates: press to start, install prompts, audio unlock, focus and pointer-lock pause,
32
+ service workers, COOP and COEP headers (without them OC fell back to one thread with no
33
+ warning).
34
+ - What the game team already built for capture.
35
+
36
+ ## Throughput and output
37
+
38
+ - Draft at 720p (25-54 fps on a quiet machine), proof risky shots at 1080p, and render 4K
39
+ last, only for the take expected to be selected. Never judge in a draft what must be
40
+ judged at 4K: OC's drafts hid "capsule mannequin" wolves and cheap bloom.
41
+ - Keep takes to 2-3 min, plan about 10 takes per kept shot, and keep shot specs as code so a
42
+ reshoot takes about 60 s to set up. OC shot 572 take lines, 23 failed, 401 were kept.
43
+ - Master: HEVC Main 8-bit at about 300 Mbps, BT.709, 2.25 GB per output minute. Proxy:
44
+ 1080p x264 CRF 23. Delivery: HEVC Main10 at about 90 Mbps (700 MB for 62 s). Hardware
45
+ `hevc_videotoolbox` took about 40 s against more than an hour for x265 under load.
46
+ - Music grid: at 105.000 BPM a beat is 34.286 frames at 60 fps. Place cuts from the beat
47
+ times; stepping a whole number of frames per beat drifts. OC landed 31 of 35 cuts within
48
+ 2 frames of the grid.
49
+ - Check every render by counting unique frames and measuring colour. OC's frame-count check
50
+ passed a cut whose first 402 frames were frozen, because two directors shared one
51
+ minute-stamped work folder.
52
+
53
+ ## Contention
54
+
55
+ Capture is the heaviest job on the machine, and it slows down when anything else runs.
56
+
57
+ - OC's 4K capture ran at a median 9.7 fps (minimum 0.47) under contention against 28-37 fps
58
+ alone. With 10 capture agents the load reached 74 on 16 cores and takes crawled at 0.7-1.1
59
+ fps.
60
+ - A second GPU browser roughly halves throughput. A background-priority LaunchAgent cut
61
+ capture from about 120 to 2-5 fps within 30 s; `taskpolicy -B` took one run from 5.6 to
62
+ 105 fps.
63
+ - Film jobs also corrupted the game team's performance numbers: one "regression" was other
64
+ browsers using CPU, and was retracted.
65
+ - Agree a written compute share before production. OC settled on 45% film, 45% game and
66
+ 10% other work only after more than 40 h of contention.
67
+ - Private build trees as full disk clones cost about 26 GB for 3 flags. Keep a disk floor
68
+ (OC's was 4 GB).
69
+
70
+ ## Process with the game team
71
+
72
+ - Film an immutable served build on its own URL, versioned by hash, with the previous
73
+ builds kept. The film will lag the live game.
74
+ - Notes to the game team go in one append-only file: the owner's words, the evidence frame,
75
+ the file and line at the frozen build, what fixed looks like, and the shot it serves.
76
+ Notes that named a cause and a number were the ones that got fixed. OC shipped 10 of 11
77
+ film notes in about 36 h once one integrator gave each note its own stream.
78
+ - Write film fixes as single flags with before and after crops, so the game can adopt them.
79
+ - Persist every override a take depends on in its spec. Keep rejected takes, so a revert is
80
+ a change of select.
81
+ - Stand up a footage log, a review page and a latest-preview link in the first hour, and
82
+ load the link yourself before sending it.