Skip to content

feat(audio): add media stream output#426

Merged
deltakosh merged 1 commit into
masterfrom
feat/audio-media-stream-output
Jul 19, 2026
Merged

feat(audio): add media stream output#426
deltakosh merged 1 commit into
masterfrom
feat/audio-media-stream-output

Conversation

@deltakosh

Copy link
Copy Markdown
Contributor

Summary

  • expose an opt-in post-master MediaStream for recording and WebRTC without changing speaker output
  • add standalone, idempotent disposal that unregisters engine cleanup and stops owned tracks
  • document the public API and cover wiring, manual disposal, engine disposal, and offline rejection

Validation

  • pnpm run lint
  • pnpm exec vitest run --project unit tests/lite/unit/audio/media-stream-output.test.ts (4 passed)
  • pnpm test (bundle-size gate passed; 427 parity tests passed; only the known unrelated scenes 47, 104, 105, 106, and 265 failed)
  • Chromium smoke check against the built package: one live audio track is created and becomes ended after disposal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b27bdb56-d938-41a9-bafe-1e401290322f
Copilot AI review requested due to automatic review settings July 19, 2026 02:58
@bjsplat

bjsplat commented Jul 19, 2026

Copy link
Copy Markdown

API Changes

API Extractor detected public API changes for @babylonjs/lite.

No removed public API lines were detected; this appears to be additive.

API Extractor diff
diff --git a/home/vsts/work/1/s/test-results/api-report/target/temp/babylon-lite.api.md b/home/vsts/work/1/s/test-results/api-report/current/temp/babylon-lite.api.md
index a6130e19..089f7ff3 100644
--- a/home/vsts/work/1/s/test-results/api-report/target/temp/babylon-lite.api.md
+++ b/home/vsts/work/1/s/test-results/api-report/current/temp/babylon-lite.api.md
@@ -470,6 +470,11 @@ export interface AudioEngine {
     readonly state: AudioEngineState;
 }
 
+// @public
+export interface AudioEngineMediaStream {
+    readonly stream: MediaStream;
+}
+
 // @public
 export interface AudioEngineOptions {
     audioContext?: BaseAudioContext;
@@ -1155,6 +1160,9 @@ export function createAudioBusAsync(engine: AudioEngine, name: string, options?:
 // @public
 export function createAudioEngineAsync(options?: AudioEngineOptions): Promise<AudioEngine>;
 
+// @public
+export function createAudioEngineMediaStream(engine: AudioEngine): AudioEngineMediaStream;
+
 // @public
 export function createAudioVisualizer(host: AudioGraphHost, canvas: HTMLCanvasElement, options?: AudioVisualizerOptions): AudioVisualizer;
 
@@ -1898,6 +1906,9 @@ export function disposeAudioBus(bus: AudioBus): void;
 // @public
 export function disposeAudioEngine(engine: AudioEngine): void;
 
+// @public
+export function disposeAudioEngineMediaStream(output: AudioEngineMediaStream): void;
+
 // @public
 export function disposeAudioVisualizer(viz: AudioVisualizer): void;

@bjsplat

bjsplat commented Jul 19, 2026

Copy link
Copy Markdown

Lite Playground - Static Site

Open deployed site

Build 20260719.1 - merge @ 0311fa6

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in MediaStream “tap” for Babylon Lite’s AudioEngine final (post-master) mix so consumers can record or forward audio (e.g., WebRTC) without changing normal speaker output, with explicit idempotent disposal and engine-owned cleanup.

Changes:

  • Introduces createAudioEngineMediaStream / disposeAudioEngineMediaStream and the AudioEngineMediaStream handle.
  • Extends the unit WebAudio mock to support createMediaStreamDestination() and a mock destination node.
  • Adds unit tests and updates architecture docs + public exports for the new API.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/lite/unit/audio/web-audio-mock.ts Adds mock createMediaStreamDestination() and MockMediaStreamAudioDestinationNode support for unit testing.
tests/lite/unit/audio/media-stream-output.test.ts New unit tests covering wiring, idempotent disposal, engine-disposal cleanup, and offline-context rejection.
packages/babylon-lite/src/index.ts Re-exports the new media-stream output API at the package root.
packages/babylon-lite/src/audio/media-stream-output.ts Implements the MediaStream output tap and safe, idempotent disposal behavior.
packages/babylon-lite/src/audio/index.ts Re-exports the new API from the audio barrel.
docs/lite/architecture/41-audio-engine.md Documents the new Lite-only media-stream output feature and updates the audio module manifest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bjsplat

bjsplat commented Jul 19, 2026

Copy link
Copy Markdown

Lab - Static Site

Open deployed site

Build 20260719.1 - merge @ 0311fa6

@deltakosh
deltakosh merged commit 9e3bbe1 into master Jul 19, 2026
13 checks passed
@deltakosh
deltakosh deleted the feat/audio-media-stream-output branch July 19, 2026 15:14
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.

3 participants