Level Meter

level-meterViewers

One bar per channel, in either orientation. The bar follows RMS — what you hear as loudness — while a thin tick marks the recent peak and bleeds back down, because on percussive material the peak is gone long before the eye catches it. Takes an analyser, a data callback, or levels your engine already computed.

L
R
L
R

Synthetic signal for display only — this demo produces no audio.

Install

Copies the source into your project. Anything it depends on comes with it.

$ npx shadcn add @syntho-ui/level-meter

Pulls in

use-audio-sourcecontrol-theme

First time? Add the registry to your components.json once:

components.json
{
  "registries": {
    "@syntho-ui": "https://engine.syntho.app/r/{name}.json"
  }
}

Usage

Controlled or uncontrolled, whichever suits the surrounding state.

example.tsx
import { LevelMeter } from "@/components/ui/level-meter"

<LevelMeter
  analyser={analyserNode}
  channels={2}
  labels={["L", "R"]}
  showScale
  segments={12}
/>

Props

PropTypeDefaultDescription
analyserAnalyserNodeA live analyser to read from. The component only ever reads it.
getData(target: Float32Array) => boolean | voidFill the array with the current frame instead of using an analyser.
valuenumber[]Pre-computed levels per channel as amplitude 0..1. Bypasses the analyser entirely.
channelsnumber1Number of bars when metering from an analyser.
orientation"vertical" | "horizontal""vertical"Which way the bars run.
lengthnumber120Long axis in pixels.
thicknessnumber10Width of each bar in pixels.
segmentsnumber0Draw as discrete LED segments rather than a continuous gradient.
peakDecaynumber0.6Peak-hold decay in full-scale units per second. 0 hides the tick.
minDecibels / maxDecibelsnumber-60 / 0The dB range the bar spans.
showScalebooleanfalseShow a dB scale beside the bars.
labelsstring[]Channel captions, e.g. ["L", "R"].

Interaction

  • Drag with pointer capture, so the gesture keeps tracking past the edge of the control.
  • Shift while dragging for a fine pass; release it mid-gesture and coarse tracking resumes.
  • Double-click resets to defaultValue.
  • Arrow keys step normally, Shift+arrow steps finely, PageUp/PageDown jump by ten, Home/End go to the extremes.
  • Proper slider and switch roles with live aria-valuetext, so a screen reader announces the formatted value rather than the raw number.
  • The scroll wheel adjusts the value while the pointer is over the control; stepped ranges move at least one declared step per notch by default.