sw-audio-level
sw-audio-level
sw-audio-level
Real-time audio-level meter rendered as a row (or column) of bars.
Pipes a MediaStream through the Web Audio API (AnalyserNode,
fftSize=256, smoothingTimeConstant=0.8) and updates an animation
loop once per frame. Each bar represents an averaged frequency band;
bar height (vertical) or width (horizontal) is proportional to the
average magnitude. Color thresholds:
--interactive-status-success)--interactive-status-warning)--interactive-button-destructive-bg)The component handles AudioContext / source / analyser teardown
automatically on disconnect, when the source changes, and when
releaseResources() is invoked. Always call releaseResources()
before stopping the underlying MediaStream tracks if you want a
clean, synchronous teardown — used by <sw-device-selector>.
If the supplied stream has no audio tracks, the component logs a warning and renders an empty meter.
Input precedence (most specific wins): .stream > .call (uses
localStream) > context (uses localStream from callStateContext).
Class: SwAudioLevel · Module: packages/web-components/src/components/sw-audio-level.ts
SwAudioLevel, sw-audio-levelExplicit MediaStream to analyze — highest precedence.
Explicit Call — when set, analyzes the call’s localStream. Bypassed by .stream if both are set.
Number of bars to display (default: 5)
Orientation of the bars: ‘vertical’ or ‘horizontal’
When true, automatically calls getUserMedia({ audio: true }) to acquire a microphone stream instead of requiring the consumer to set .stream.
Maximum height/width of bars in pixels