PluginUI

Spectrum

spectrumVisualizers

Plots magnitude against frequency on a logarithmic axis. A linear axis would spend half its width above 10 kHz, where little musically interesting happens, while compressing the bass into a few pixels. Each bar takes the loudest bin in its band, so a narrow peak is never averaged into invisibility.

Bone / Studio
Loading interactive preview…
Planar / Flat
Loading interactive preview…
Midnight / Minimal
Loading interactive preview…
Ember / Vintage
Loading interactive preview…
Ink / Studio
Loading interactive preview…
Mint / Flat
Loading interactive preview…

Install

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

$ pnpm dlx shadcn@latest add @pluginui/core-spectrum

Pulls in

use-audio-sourcecontrol-theme

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

components.json
{
  "registries": {
    "@pluginui": "https://pluginui.com/r/{name}.json"
  }
}

Usage

Connect the documented props to your application or host.

example.tsx
import { Spectrum } from "@/components/ui/spectrum"

<Spectrum analyser={analyserNode} variant="bars" bars={48} />

Props

PropTypeDefaultDescription
analyserAnalyserNode—A live analyser to read frequency data from.
getData(target: Float32Array) => boolean | void—Supply dB magnitudes yourself instead of using an analyser.
variant"bars" | "curve""bars"Discrete bars, or a filled line across the bins.
barsnumber48Number of bars. Ignored by the curve variant.
scale"log" | "linear""log"Frequency axis scaling. Log is the musically useful one.
minFrequency / maxFrequencynumber20 / NyquistThe frequency range shown.
minDecibels / maxDecibelsnumber-90 / -10The magnitude range mapped to the display height.
sampleRatenumber—Needed for the frequency axis when driving from getData.
heightnumber140Display height in pixels; width defaults to 100%.

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.