From 6cb48c043be564452cd0f3ede5afdd63932fc440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sat, 15 Aug 2026 19:48:51 +0000 Subject: [PATCH] fix(studio): stabilize previews and normalize clip audio Persist agent preview processes safely and support above-unity gain in preview and render. Add a measured LUFS normalizer for matching local authored clips. --- docs/packages/cli.mdx | 37 +- packages/cli/README.md | 24 +- packages/cli/src/cli.ts | 1 + .../cli/src/commands/coreSkillContent.test.ts | 11 + .../cli/src/commands/normalize-audio.test.ts | 133 +++ packages/cli/src/commands/normalize-audio.ts | 546 ++++++++++++ packages/cli/src/commands/preview.test.ts | 383 +++++++- packages/cli/src/commands/preview.ts | 832 ++++++++++++++---- .../cli/src/commands/previewLifecycle.test.ts | 341 ++++++- packages/cli/src/commands/previewLifecycle.ts | 247 +++++- .../commands/previewLifecycleOutput.test.ts | 83 ++ .../src/commands/previewLifecycleOutput.ts | 59 ++ packages/cli/src/server/portUtils.ts | 46 +- packages/cli/src/templates/_shared/AGENTS.md | 13 +- packages/cli/src/templates/_shared/CLAUDE.md | 13 +- packages/cli/src/utils/orphanCleanup.test.ts | 47 +- packages/cli/src/utils/orphanCleanup.ts | 121 ++- packages/cli/src/utils/studioProxyEnv.test.ts | 18 + packages/cli/src/utils/studioProxyEnv.ts | 14 + packages/core/package-subpaths.json | 6 + packages/core/package.json | 10 + packages/core/src/audioGain.test.ts | 36 + packages/core/src/audioGain.ts | 54 ++ packages/core/src/runtime/init.ts | 2 +- packages/core/src/runtime/media.test.ts | 19 + packages/core/src/runtime/media.ts | 27 +- .../src/runtime/webAudioTransport.test.ts | 9 + .../core/src/runtime/webAudioTransport.ts | 5 +- .../engine/src/services/audioMixer.test.ts | 29 + packages/engine/src/services/audioMixer.ts | 4 +- packages/parsers/src/types.ts | 2 +- .../propertyPanelFlatMediaSection.test.tsx | 20 +- .../editor/propertyPanelFlatMediaSection.tsx | 24 +- .../editor/propertyPanelMediaSection.tsx | 21 +- packages/studio/vite.config.ts | 9 + packages/studio/vite.preview-config.test.ts | 30 + packages/studio/vite.preview-config.ts | 22 + skills-manifest.json | 16 +- skills/faceless-explainer/SKILL.md | 2 +- .../hyperframes-audio/references/diagnosis.md | 35 + skills/hyperframes-cli/SKILL.md | 4 +- .../references/preview-render.md | 14 +- skills/hyperframes-core/SKILL.md | 2 +- .../references/review-loop.md | 2 +- skills/motion-graphics/SKILL.md | 2 +- skills/product-launch-video/SKILL.md | 2 +- skills/slideshow/SKILL.md | 2 +- skills/talking-head-recut/SKILL.md | 2 +- 48 files changed, 3050 insertions(+), 331 deletions(-) create mode 100644 packages/cli/src/commands/normalize-audio.test.ts create mode 100644 packages/cli/src/commands/normalize-audio.ts create mode 100644 packages/cli/src/commands/previewLifecycleOutput.test.ts create mode 100644 packages/cli/src/commands/previewLifecycleOutput.ts create mode 100644 packages/core/src/audioGain.test.ts create mode 100644 packages/core/src/audioGain.ts create mode 100644 packages/studio/vite.preview-config.test.ts create mode 100644 packages/studio/vite.preview-config.ts diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index ffb25e040b..d4e18da596 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -23,7 +23,7 @@ npm install -g hyperframes | You want to | Use | | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Start a project | [`init`](#init), [`add`](#add), [`catalog`](#catalog) | -| Bring in source material | [`capture`](#capture), [`transcribe`](#transcribe), [`tts`](#tts), [`remove-background`](#remove-background), [`media-treatment`](#media-treatment), [`beats`](#beats) | +| Bring in source material | [`capture`](#capture), [`transcribe`](#transcribe), [`tts`](#tts), [`remove-background`](#remove-background), [`media-treatment`](#media-treatment), [`beats`](#beats), [`normalize-audio`](#normalize-audio) | | Look at it, or share it | [`preview`](#preview), [`present`](#present-and-play), [`play`](#present-and-play), [`publish`](#publish) | | Find problems | [`lint`](#lint), [`check`](#check), [`snapshot`](#snapshot), [`keyframes`](#keyframes), [`compare`](#compare-and-grade-compare), [`grade-compare`](#compare-and-grade-compare) | | Make a file | [`render`](#render), [`benchmark`](#benchmark) | @@ -428,6 +428,30 @@ Needs a local Chrome, the same one `render` uses. Run within a frame or two — a different headless-Chrome audio sample rate can shift a beat slightly. +### `normalize-audio` + +Match one authored audio clip to a reference using the exact local media bytes +and FFmpeg's integrated EBU R128 loudness measurement. + +```bash +# Measure only (the default) +npx hyperframes normalize-audio --reference target-audio --target user-audio + +# Persist the computed gain on #user-audio +npx hyperframes normalize-audio --reference target-audio --target user-audio --write + +# Agent-readable result +npx hyperframes normalize-audio --reference target-audio --target user-audio --json +``` + +`--reference` and `--target` are `