diff --git a/packages/cli/src/commands/normalize-audio.command.test.ts b/packages/cli/src/commands/normalize-audio.command.test.ts
index ad034f708e..17820aa3df 100644
--- a/packages/cli/src/commands/normalize-audio.command.test.ts
+++ b/packages/cli/src/commands/normalize-audio.command.test.ts
@@ -127,6 +127,35 @@ describe("normalize-audio on a clip inside a mounted scene", () => {
});
});
+describe("absolute normalize-audio command held by a limit", () => {
+ it("prints the level the clip plays at, its data-volume included", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "hf-normalize-absolute-held-test-"));
+ const log = vi.spyOn(console, "log").mockImplementation(() => {});
+ try {
+ const path = join(dir, "index.html");
+ const html = ``;
+ writeFileSync(path, html);
+ writeFileSync(join(dir, "voice.wav"), "audio bytes");
+ measureAudio.mockResolvedValue({ integratedLufs: -20, truePeakDbfs: -7.8 });
+
+ await runCommand(normalizeAudioCommand, {
+ rawArgs: [dir, "--target", "voice", "--lufs", "-12", "--write"],
+ });
+
+ const printed = log.mock.calls.map((call) => String(call[0])).join("\n");
+ expect(printed).toContain(
+ "-20.0 LUFS → -14.0 LUFS, target -12.0 (stopped short of -1.5 dBTP)",
+ );
+ expect(printed).toContain("Cannot get closer to the target; the gain is unchanged.");
+ expect(readFileSync(path, "utf8")).toBe(html);
+ } finally {
+ log.mockRestore();
+ measureAudio.mockReset();
+ rmSync(dir, { recursive: true, force: true });
+ }
+ });
+});
+
describe("reference normalize-audio command", () => {
it("writes the most gain that stays under -1.5 dBTP and says how far under the reference that leaves it", async () => {
const dir = mkdtempSync(join(tmpdir(), "hf-normalize-reference-test-"));
@@ -160,4 +189,36 @@ describe("reference normalize-audio command", () => {
rmSync(dir, { recursive: true, force: true });
}
});
+
+ it("says where the target stays when the ceiling leaves less gain than the tolerance", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "hf-normalize-reference-held-test-"));
+ const log = vi.spyOn(console, "log").mockImplementation(() => {});
+ try {
+ const path = join(dir, "index.html");
+ const html =
+ `` +
+ ``;
+ writeFileSync(path, html);
+ writeFileSync(join(dir, "open.wav"), "audio bytes");
+ writeFileSync(join(dir, "close.wav"), "audio bytes");
+ measureAudio
+ .mockResolvedValueOnce({ integratedLufs: -15, truePeakDbfs: -3 })
+ .mockResolvedValueOnce({ integratedLufs: -18, truePeakDbfs: -1.8 });
+
+ await runCommand(normalizeAudioCommand, {
+ rawArgs: [dir, "--reference", "speaker-opening", "--target", "speaker-closing", "--write"],
+ });
+
+ const printed = log.mock.calls.map((call) => String(call[0])).join("\n");
+ expect(printed).toContain(
+ "Stays at -18.0 LUFS, 3.0 dB under the reference (stopped short of -1.5 dBTP).",
+ );
+ expect(printed).toContain("Cannot get closer to the target; the gain is unchanged.");
+ expect(readFileSync(path, "utf8")).toBe(html);
+ } finally {
+ log.mockRestore();
+ measureAudio.mockReset();
+ rmSync(dir, { recursive: true, force: true });
+ }
+ });
});
diff --git a/packages/cli/src/commands/normalize-audio.ts b/packages/cli/src/commands/normalize-audio.ts
index adbb06701e..20a9bf384e 100644
--- a/packages/cli/src/commands/normalize-audio.ts
+++ b/packages/cli/src/commands/normalize-audio.ts
@@ -77,6 +77,8 @@ interface WriteOutcome {
ok: true;
wrote: boolean;
withinTolerance: boolean;
+ heldByLimit: boolean;
+ reachedLufs: number;
tolerance: number;
filePath: string;
}
@@ -198,7 +200,17 @@ async function normalizeAudio(options: NormalizeAudioOptions): Promise 0 && heldAtLimit(result, result.tolerance)) {
+ if (result.heldByLimit) {
console.log(c.dim("Cannot get closer to the target; the gain is unchanged."));
return;
}