From 2cd43a3a786be1baaa29509d8320ef3f4c67f48a Mon Sep 17 00:00:00 2001
From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Date: Wed, 10 Jun 2026 20:25:44 -0700
Subject: [PATCH 1/2] =?UTF-8?q?feat(core,engine):=20data-duck=20=E2=80=94?=
=?UTF-8?q?=20compile-time=20audio=20ducking=20under=20voice=20tracks?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/concepts/data-attributes.mdx | 29 +++
docs/docs.json | 1 +
docs/guides/music-voiceover.mdx | 32 +++
docs/reference/html-schema.mdx | 25 +++
packages/core/src/compiler/htmlCompiler.ts | 5 +-
packages/core/src/compiler/index.ts | 1 +
.../core/src/compiler/timingCompiler.test.ts | 59 +++++
packages/core/src/compiler/timingCompiler.ts | 211 +++++++++++++++++-
packages/core/src/index.test.ts | 1 +
packages/core/src/index.ts | 1 +
.../core/src/runtime/mediaVolumeEnvelope.ts | 170 +++++++++++++-
.../engine/src/services/audioElementParser.ts | 69 ++++++
.../engine/src/services/audioMixer.test.ts | 40 +++-
packages/engine/src/services/audioMixer.ts | 60 +----
.../src/services/htmlCompiler.test.ts | 51 +++++
.../producer/src/services/htmlCompiler.ts | 5 +-
.../src/services/render/stages/probeStage.ts | 14 +-
17 files changed, 698 insertions(+), 76 deletions(-)
create mode 100644 docs/guides/music-voiceover.mdx
create mode 100644 packages/engine/src/services/audioElementParser.ts
diff --git a/docs/concepts/data-attributes.mdx b/docs/concepts/data-attributes.mdx
index ed1caaff1..2ee08dd49 100644
--- a/docs/concepts/data-attributes.mdx
+++ b/docs/concepts/data-attributes.mdx
@@ -20,6 +20,35 @@ Hyperframes uses HTML data attributes to control timing, media playback, and [co
| `data-media-start` | `"2"` | Media playback offset / trim point in seconds. Default: `0` |
| `data-volume` | `"0.8"` | Audio/video volume, 0 to 1 |
| `data-has-audio` | `"true"` | Indicates video has an audio track |
+| `data-role` | `"voice"` | Marks narration or dialogue that should trigger ducking |
+| `data-duck` | `"-12dB"` | Lowers this track while audible `data-role="voice"` clips overlap it |
+| `data-duck-fade` | `"0.3"` | Ducking ramp duration in seconds. Default: `0.3` |
+
+## Music Ducking
+
+Use `data-duck` on background music and `data-role="voice"` on narration or dialogue. Hyperframes computes the overlap windows from clip timing and renders the result through the same volume automation path used for authored fades.
+
+```html index.html
+
+
+```
+
+`data-duck` accepts dB values (`"-12dB"` or `"-12"`) and linear gains (`"0.25"`). `data-duck-fade` controls the ramp into and out of the ducked level. Runtime-triggered audio that is not represented as timed `