mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
fix(lint): audio_volume_tween_overrides_gain hint keeps the level the author set (#8689)
* fix(lint): audio_volume_tween_overrides_gain hint keeps the level the agent set The hint offered resetting data-volume to 1 as a way out, and agents took it to clear the warning, which threw away a level they had chosen. The hint now names the clip's own gain as the tween target to write and says to measure the render with `hyperframes audio` before changing the level. * test(lint): protect authored gain advice for quiet clips * fix(lint): clarify silent clip choices and align gain docs
This commit is contained in:
@@ -590,7 +590,7 @@ Source: `packages/lint/src/rules/media.ts`.
|
||||
|
||||
**Warning.** An element has `data-volume` gain and a GSAP tween on `volume`; tween values are absolute and replace the gain rather than scale it.
|
||||
|
||||
**Fix:** Write tween targets as absolute gains that already include the gain, or reset `data-volume` to 1 and let the tween carry the level.
|
||||
**Fix:** Keep the level you set. Use an absolute gain for each level the tween should reach: for `data-volume="0.3"`, use `volume: 0.3` where it should reach that level, and keep `volume: 0` at endpoints intended to be silent. If `data-volume="0"`, the clip is authored silent: drop the volume tween to keep it silent, or deliberately set `data-volume="1"` and let the tween carry the level. If the level is in doubt, measure the rendered file with `hyperframes audio render.mp4` (replace `render.mp4` with your output file) before changing it.
|
||||
|
||||
### `base64_media_prohibited`
|
||||
|
||||
|
||||
@@ -957,13 +957,42 @@ describe("audio_volume_tween_overrides_gain", () => {
|
||||
expect(finding?.severity).toBe("warning");
|
||||
expect(finding?.elementId).toBe("bgm");
|
||||
expect(finding?.message).toMatch(/5\.8 dB/);
|
||||
expect(finding?.fixHint).toContain("`volume: 1.949845`");
|
||||
});
|
||||
|
||||
it("warns about an attenuation the tween overrides, not just a boost", async () => {
|
||||
it.each([
|
||||
["0.3", "0.3"],
|
||||
["1.95", "1.95"],
|
||||
["0.030000", "0.03"],
|
||||
["3e-2", "0.03"],
|
||||
])("preserves the authored gain %s in its advice", async (authored, gain) => {
|
||||
const res = await lintHyperframeHtml(
|
||||
withScript(`data-volume="0.3"`, `tl.to("#bgm", { volume: 1 });`),
|
||||
withScript(`data-volume="${authored}"`, `tl.to("#bgm", { volume: 1 });`),
|
||||
);
|
||||
expect(res.findings.some((f) => f.code === "audio_volume_tween_overrides_gain")).toBe(true);
|
||||
const finding = res.findings.find((f) => f.code === "audio_volume_tween_overrides_gain");
|
||||
expect(finding?.severity).toBe("warning");
|
||||
expect(finding?.elementId).toBe("bgm");
|
||||
expect(finding?.fixHint).toContain(`\`volume: ${gain}\``);
|
||||
expect(finding?.fixHint).toContain(
|
||||
"measure the rendered file with `hyperframes audio render.mp4`",
|
||||
);
|
||||
expect(finding?.fixHint).toContain("keep `volume: 0` at endpoints intended to be silent");
|
||||
expect(finding?.fixHint).not.toContain('data-volume="1"');
|
||||
expect(finding?.fixHint).not.toContain("`volume: 1`");
|
||||
});
|
||||
|
||||
it("names both deliberate choices for an authored silent clip", async () => {
|
||||
const res = await lintHyperframeHtml(
|
||||
withScript(`data-volume="0"`, `tl.fromTo("#bgm", { volume: 0 }, { volume: 1 });`),
|
||||
);
|
||||
const finding = res.findings.find((f) => f.code === "audio_volume_tween_overrides_gain");
|
||||
expect(finding?.severity).toBe("warning");
|
||||
expect(finding?.message).toContain("(silence)");
|
||||
expect(finding?.fixHint).toContain('authored silent (`data-volume="0"`)');
|
||||
expect(finding?.fixHint).toContain("To keep it silent, drop the volume tween");
|
||||
expect(finding?.fixHint).toContain('to let the tween carry the level, set `data-volume="1"`');
|
||||
expect(finding?.fixHint).toContain("choose its absolute volume targets deliberately");
|
||||
expect(finding?.fixHint).toContain("hyperframes audio render.mp4");
|
||||
});
|
||||
|
||||
it("stays quiet on the fade the docs recommend, which carries no data-volume", async () => {
|
||||
|
||||
@@ -927,7 +927,10 @@ function findVolumeTweenOverridesGainFindings(ctx: LintContext): HyperframeLintF
|
||||
message: `#${id} has data-volume="${volume}" (${db}) and a GSAP tween on \`volume\`. Tween values are absolute: they REPLACE this gain rather than scale it, so wherever the tween names a value the clip plays at that value, not at ${db}.`,
|
||||
elementId: id,
|
||||
fixHint:
|
||||
"Write the tween's targets in the same absolute gain (e.g. `volume: 1.95`, not `volume: 1`), or reset data-volume to 1 and let the tween carry the level on its own.",
|
||||
(volume === 0
|
||||
? 'This clip is authored silent (`data-volume="0"`). To keep it silent, drop the volume tween; to let the tween carry the level, set `data-volume="1"` and choose its absolute volume targets deliberately. '
|
||||
: `Keep the level you set: use an absolute gain for each level the tween should reach. Use \`volume: ${volume}\` where it should reach this clip's authored level; keep \`volume: 0\` at endpoints intended to be silent. `) +
|
||||
"If the level is in doubt, measure the rendered file with `hyperframes audio render.mp4` (replace render.mp4 with your output file) before changing it.",
|
||||
snippet: truncateSnippet(tag.raw),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user