audiocn

Spectrum

A frequency spectrum analyser with axes, a grid and peak hold.

Installation

$ pnpm dlx shadcn@latest add @audiocn/spectrum

Usage

import { Spectrum } from "@/components/ui/spectrum";
const analyser = useAudioAnalyser(stream, { bands: 64 });

<Spectrum source={analyser.visual} />;

The spectrum draws the frequency bands of a visual frame. Set minHz, maxHz, minDb and maxDb to match the analyser that produced them, so the axes are labelled correctly. The defaults match useAudioAnalyser.

Anatomy

<Spectrum>
  <SpectrumLevelAxis />
  <SpectrumCanvas />
  <SpectrumFrequencyAxis />
</Spectrum>

Examples

Line and area

Microphone

Theming

VariableDefault
--spectrumprimary
--spectrum-peakforeground
--spectrum-gridborder

API reference

Prop

Type