For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReferenceClick-to-Call
GuidesReferenceClick-to-Call
  • Core
    • Overview
  • Entities
    • SignalWire
    • Address
    • Participant
    • ClientPreferences
    • SelfCapabilities
    • SelfParticipant
    • User
    • WebRTCCall
  • Web Components
    • Overview
    • sw-audio-level
    • sw-call-controls
    • sw-call-dialpad
    • sw-call-media
    • sw-call-provider
    • sw-call-status
    • sw-call-widget
    • sw-click-to-call
    • sw-device-selector
    • sw-directory
    • sw-local-camera
    • sw-participant-controls
    • sw-participants
    • sw-self-media
    • sw-ui-alert
    • sw-ui-background
    • sw-ui-call-layout
    • sw-ui-content-drawer
    • sw-ui-control-bar
    • sw-ui-dialpad
    • sw-ui-dropup
    • sw-ui-icon
    • sw-ui-modal
    • sw-ui-responsive-container
    • sw-ui-split-button
    • sw-ui-transcript-view
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • class: SwAudioLevel, sw-audio-level
  • Fields
  • stream
  • call
  • bars
  • orientation
  • autoRequest
  • maxSize
  • Methods
  • Attributes
  • CSS Properties
  • CSS Parts
Web Components

sw-audio-level

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

sw-call-controls

Next
Built with

Real-time audio-level meter rendered as a row (or column) of bars.

1<sw-audio-level></sw-audio-level>

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:

  • level > 0.05 → bar becomes “active” (--interactive-status-success)
  • level > 0.40 → yellow (--interactive-status-warning)
  • level > 0.70 → red (--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

class: SwAudioLevel, sw-audio-level

Fields

stream
MediaStream | undefined

Explicit MediaStream to analyze — highest precedence.

call
Call | undefined

Explicit Call — when set, analyzes the call’s localStream. Bypassed by .stream if both are set.

bars
numberDefaults to 5

Number of bars to display (default: 5)

orientation
'vertical' | 'horizontal'Defaults to 'vertical'

Orientation of the bars: ‘vertical’ or ‘horizontal’

autoRequest
booleanDefaults to false

When true, automatically calls getUserMedia({ audio: true }) to acquire a microphone stream instead of requiring the consumer to set .stream.

maxSize
numberDefaults to 32

Maximum height/width of bars in pixels

Methods

NamePrivacyDescriptionParametersReturnInherited From
releaseResourcespublicPublic method to release all audio resources immediately Call this before stopping the MediaStream tracks to ensure proper cleanupvoid

Attributes

NameFieldInherited From
streamstream
callcall
barsbars
orientationorientation
auto-requestautoRequest
maxSizemaxSize

CSS Properties

NameDefaultDescription
--interactive-status-success#22c55eColor for low audio levels.
--interactive-status-warning#ffd700Color for medium audio levels.
--interactive-button-destructive-bg#dc2626Color for high audio levels.
--sw-audio-bar-width4pxWidth of each vertical bar (height when horizontal).
--sw-audio-bar-gap2pxGap between audio level bars.
--sw-audio-bar-radius2pxBorder radius of each bar.
--sw-audio-bar-backgroundrgba(255,255,255,0.2)Background color of inactive bars.

CSS Parts

NameDescription
containerThe flex container holding all bars. Style for layout, padding, or background.
barEvery individual bar element.
bar-activeApplied additionally when the bar is above the activity threshold (~5% of full scale). Lets you style silent vs. active bars differently.