Live Waveform

PreviousNext

Real-time canvas-based audio waveform visualizer with microphone input and customizable rendering modes.

Installation

pnpm dlx @elevenlabs/agents-cli@latest components add live-waveform

Usage

import { LiveWaveform } from "@/components/ui/live-waveform"
<LiveWaveform active={true} />

Examples

Static Mode

<LiveWaveform active={true} mode="static" />

Scrolling Mode

<LiveWaveform active={true} mode="scrolling" />

Processing State

Shows an animated wave pattern while waiting for input.

<LiveWaveform processing={true} mode="static" />

Custom Styling

<LiveWaveform
  active={true}
  barWidth={4}
  barGap={2}
  barColor="#3b82f6"
  height={100}
  fadeEdges={true}
/>

API Reference

LiveWaveform

A canvas-based real-time audio visualizer with microphone input support.

Props

PropTypeDefaultDescription
activebooleanfalseWhether to actively listen to microphone input
processingbooleanfalseShow processing animation when not active
barWidthnumber3Width of each bar in pixels
barGapnumber1Gap between bars in pixels
barRadiusnumber1.5Border radius of bars
barColorstring-Color of the bars (defaults to text color)
fadeEdgesbooleantrueWhether to fade the edges of the waveform
fadeWidthnumber24Width of the fade effect in pixels
heightstring | number64Height of the waveform
sensitivitynumber1Audio sensitivity multiplier
smoothingTimeConstantnumber0.8Audio analyser smoothing (0-1)
fftSizenumber256FFT size for audio analysis
historySizenumber60Number of bars to keep in history (scrolling)
updateRatenumber30Update rate in milliseconds
mode"scrolling" | "static""static"Visualization mode
onError(error: Error) => void-Error callback
onStreamReady(stream: MediaStream) => void-Callback when stream is ready
onStreamEnd() => void-Callback when stream ends
classNamestring-Custom CSS class
...propsHTMLDivElement-All standard div element props

Notes

  • Uses Web Audio API for real-time frequency analysis
  • Automatically requests microphone permissions when active={true}
  • Canvas-based rendering with HiDPI support
  • Properly cleans up media streams and audio contexts on unmount
  • Static mode: Displays symmetric waveform bars across multiple frequency bands (detailed visualization)
  • Scrolling mode: Shows historical average audio volume as bars scrolling from right to left (timeline view)
  • Processing state: Shows animated waves while waiting for input
  • Smooth transitions between active, processing, and idle states
  • Scrolling mode builds up history gradually - bars appear from right and fill over time