mirror of
https://github.com/SrIzan10/vdo.ninja.git
synced 2026-05-01 11:05:24 +00:00
2.8 KiB
2.8 KiB
Audio Meter Pipeline Spec
Legacy Behavior
- Inbound audio tracks enter
session.rpcs[UUID].inboundAudioPipelinewhereaudioMeterGuest()injects anAnalyserNode(lib.js:46573-47782). - Loudness is computed by averaging FFT bins every 100 ms and mapped to DOM meters (
voiceMeterelements) with style variants selected viasession.meterStyle(lib.js:47703-47771). - Meter values also feed optional features like
session.pushLoudness, active-speaker highlighting, and iframe postMessage events. - Meter UI updates live inside the analyser loop, coupling audio processing with DOM manipulation.
Podcast Studio Requirements
- Per-track telemetry: expose peak, RMS, and clip count per participant stream.
- Low-latency visuals: 30–60 FPS updates for waveform bars in the studio shell, separate from DOM-heavy legacy meters.
- Extensible alerts: thresholds for clipping, silence detection, and noisy floors.
- Headless access: other modules (recording, AI markers) should subscribe without touching DOM.
Proposed Architecture
MediaStreamTrack
└─▶ MeterNode (AudioWorklet + SharedArrayBuffer)
├─▶ LevelBus.publish({ uuid, peak, rms, crest, clipped })
└─▶ Optional legacy bridge updates DOM meters via event listener
Studio UI (podcast-shell)
└─▶ subscribes to LevelBus for visual meters, notifications, analytics
Recording Service
└─▶ listens for clip/silence to insert markers, trigger backups
MeterNode Design
- Build an
AudioWorkletProcessor(core/meter.worklet.js) that computes:- Instantaneous peak (max absolute sample).
- RMS over 1024-sample windows.
- Clipped sample counter (threshold > -1 dBFS).
- Post results through a
MessagePortto the main thread every 32 ms, keeping GC pressure low. - Provide
connect(stream, { uuid })helper incore/audio/meters.js.
Event Bus
- Introduce
LevelBusas a lightweightEventTargetincore/events/level-bus.js. - Emit
levelevents with payload{ uuid, trackId, peak, rms, clipped, timestamp }. - Legacy UI can attach a listener that maps to existing
voiceMeterDOM updates until replaced.
Thresholds & Alerts
- Default clip alert:
peak >= -1 dBFSfor three consecutive frames. - Silence alert:
rms <= -60 dBFSfor >3 seconds. - Provide
LevelPolicyconfiguration for per-room overrides.
Implementation Steps
- Implement
MeterWorkletProcessorand register viaaudioContext.audioWorklet.addModule(). - Wrap legacy
audioMeterGuestto forward analyser metrics intoLevelBusbefore modifying DOM. - Update podcast studio shell to subscribe for UI meters, enabling waveform/LED displays.
- Expose metrics to recording service for embedding markers in local/remote tracks.