Skip to content

feat(core): capture.data runtime inputs + host-supplied audio producer for capture templates - #45

Merged
hblee12294 merged 1 commit into
mainfrom
feat/capture-data-audio-producer
Jul 17, 2026
Merged

feat(core): capture.data runtime inputs + host-supplied audio producer for capture templates#45
hblee12294 merged 1 commit into
mainfrom
feat/capture-data-audio-producer

Conversation

@hblee12294

Copy link
Copy Markdown
Member

What

Two additive capabilities for the capture templates:

  • capture.data — JSON-injected into the page and passed to initVos as deps.data, in both capture-video and capture-thumbnail modes. Compositions built on the interpreter pattern (constant program, inputs in ctx.data) previously captured with only the config's baked data — server captures of data-dependent compositions were silently wrong. Runtime docs already state deps.data overrides baked data; capture modes now honor that contract.
  • capture.audioProducerCode (capture-video) — a host-supplied script that defines window.__vosAudioProducer__ = async ({ data, duration, sampleRate }) => AudioBuffer | null. The template runs it before the frame loop (a producer failure aborts early instead of wasting the render) and muxes the returned buffer as the output's audio track: AAC for mp4 with an automatic Opus fallback via canEncodeAudio (AAC encode is unavailable on some platforms, e.g. desktop Linux), Opus for webm. Returning null captures video-only.

The engine stays schema-agnostic: it imposes no audio model — how a producer interprets data (mixing, envelopes, sources) is entirely the host's concern, consistent with "add capabilities, not conventions."

Compatibility

Fully backward compatible: without capture.data the page emits deps.data untouched behavior (null sentinel, no assignment); without a producer, zero audio code is emitted — byte-wise the only change to existing templates is the null data sentinel line.

Tests

5 new template assertions (data injection in both modes, null default, producer embedding + mux plumbing, aac/opus preference matrix, no-producer emits no audio code) — 128 pass across the core suite; typecheck, lint, build clean. Changeset: minor.

🤖 Generated with Claude Code

…ture templates

- capture.data: JSON-injected and passed to initVos as deps.data in both
  capture-video and capture-thumbnail modes. Data-dependent compositions
  (constant program, inputs in ctx.data) previously rendered with baked
  config data only — server captures of such compositions were wrong.
- capture.audioProducerCode: host-supplied script defining
  window.__vosAudioProducer__({ data, duration, sampleRate }) ->
  AudioBuffer | null. The template runs it before the frame loop and muxes
  the buffer as the output's audio track — AAC for mp4 with an automatic
  Opus fallback (AAC encode is unavailable on some platforms), Opus for
  webm. The engine stays schema-agnostic: how the producer interprets data
  is the host's concern. No producer = zero audio code emitted.
@hblee12294
hblee12294 merged commit 32a69a9 into main Jul 17, 2026
3 checks passed
@hblee12294
hblee12294 deleted the feat/capture-data-audio-producer branch July 17, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant