audiocn: React Audio Components for shadcn/ui

Get real dB controls, live audio analysis, device capture, waveform data, and editable React source from one shadcn registry.

audiocn is a React and shadcn/ui component registry that installs audio meters, visualizers, controls, players, and mixer UI as editable source files.

It is built for browser audio apps that work with real dB values and Web Audio data. The shadcn CLI copies each registry item into the project, where the code can be edited locally.

Features

  • 20+ React audio components for metering, visualization, mixing, playback, and sound triggering.
  • 6+ audio blocks for system mixing, microphone setup, soundboards, music playback, system-audio controls, and quick audio access.
  • 15+ hooks for capture, analysis, mixer state, playback, devices, waveform data, frame sources, and audio state.
  • Tailwind CSS styling with shadcn theme tokens and six audio-specific color tokens.
  • Base UI primitives for interactive controls.
  • Decibel-based meters, faders, and mixer controls.
  • Animation-frame painting for meters and visualizers outside React render cycles.
  • Keyboard control, ARIA meter state, and reduced-motion behavior.

Use Cases

  • Recording and streaming dashboards with peak/RMS meters, clipping state, gain, pan, mute, solo, and monitoring.
  • Microphone setup screens with device selection, live levels, gain, mute, and permission state.
  • Music or podcast players with waveform seeking, track navigation, loop, playback rate, and volume.
  • Soundboards and browser audio apps that need hotkeys, short-sound playback, system-audio capture, or reusable mixer controls.

How to Use audiocn

Initialize shadcn/ui

Run the initializer when the project does not have a components.json file:

npx shadcn@latest init

Register audiocn

Set the @audiocn namespace in components.json:

{
  "registries": {
    "@audiocn": "https://audiocn.dev/r/{name}.json"
  }
}

Install a Component or Block

Install components with the shadcn CLI:

npx shadcn@latest add @audiocn/level-meter

The System Audio Mixer pulls in most of the library:

npx shadcn@latest add @audiocn/system-audio-mixer

Basic Usage

import { LevelMeter } from "@/components/ui/level-meter";
export const MicLevel = ({ peakDb }: { peakDb: number }) => (
  <LevelMeter aria-label="Microphone level" peakDb={peakDb} />
);

Default File Placement

The CLI follows the aliases in components.json. A project using src/ or custom aliases receives the files under those mapped locations.

Default LocationContents
components/ui/*Component source files
hooks/use-*.tsFrame-source, Web Audio, playback, device, and mixer hooks
lib/audio/*.tsDecibel math, ballistics, tapers, frame loops, frame sources, and shared audio types
app/globals.cssAudio theme tokens

Available Components

CategoryComponentsMain Task
Meters and visualizersLevel Meter, dB Scale, dB Readout, Clip Indicator, Bar Visualizer, Electric Bar Visualizer, Electric Waveform, Smooth Waveform, Live Waveform, Waveform, SpectrumPeak/RMS metering, clipping, frequency bands, live signals, recorded clips, spectrum data
ControlsFader, Parameter Slider, Knob, Pan Control, Channel Toggle, Volume Control, Audio Device SelectGain and parameter input, pan, mute, solo, monitor, player volume, device selection
MixerChannel Strip, MixerChannel layouts, shared meter settings, keyboard navigation, master controls
Sounds and musicAudio Player, Track List, Sound PadTransport, seeking, playlists, short-sound triggering

Audio Blocks

BlockMain Task
System Audio MixerMicrophone, system audio, music, sound pads, channel controls, metering, master output
Music PlayerPlaylist playback, waveform seeking, shuffle, repeat, volume, ducking
SoundboardSound pads, hotkeys, trigger modes, volume, stop-all control, drag-and-drop
Microphone SetupDevice selection, live preview, metering, gain, mute, level checks
Quick Audio PopoverMicrophone and system-audio controls inside a toolbar popover
System Audio SettingsSystem-audio capture, level control, metering

Audio Hooks

HookMain Task
useMicrophoneOpens a microphone as a MediaStream
useSystemAudioCaptures system or tab audio through the browser screen-share picker
useAudioAnalyserCreates meter and visualizer frame sources from a stream, media element, or AudioNode
useWebAudioMixerConnects mixer state to a Web Audio graph with ducking, monitor sends, and a limited master
useMixerManages gain, mute, solo, pan, monitor, and master state with no attached audio graph
useAudioPlayerManages playback state for an owned audio element
useSoundPlays short decoded sounds from memory
useWaveformDataDecodes an audio file into cached waveform peaks
useAudioDevicesTracks audio input or output devices, permission state, and device changes
useDemoSignalGenerates speech, music, tone, or noise frame data for previews and tests
useAudioContextReturns the shared or supplied AudioContext and resumes it after the first user gesture
useFrameSourceSubscribes a callback to a frame source with automatic cleanup
useLevelSamples meter data into React state at a low rate for labels and conditional UI
useClipHoldTracks clipping, hold time, clip count, and reset state
useReducedMotionReads the system reduced-motion preference
useAudioConfigReads config from the nearest mixer or channel strip

LevelMeter API

PropType / DefaultPurpose
sourceFrameSource<MeterFrame> | nullLive meter frames
peakDbnumberDeclarative mono peak level in dBFS
rmsDbnumberDeclarative mono RMS level in dBFS
channelsChannelLevel[]Declarative multi-channel levels
channelCountnumber / 1Tracks rendered before frame data arrives
minDbnumber / -60Bottom of the displayed range
maxDbnumber / 0Top of the displayed range
zonesMeterZone[] / DEFAULT_ZONESok, warn, and clip level zones
ballistics"peak" | "vu" | "instant" | Partial<BallisticsOptions> / "peak"Meter movement model
taper"linear" | "audio" | Taper / "linear"Scale law
orientation"horizontal" | "vertical" / "horizontal"Meter direction
variant"solid" | "segmented" | "gradient" / "solid"Meter rendering style
segmentsnumber / 24LED segment count
size"sm" | "default" | "lg" / "default"Track thickness
actionsRefRef<LevelMeterActions>Direct paint(frame) and reset() access

Styling and Theming

audiocn uses standard shadcn tokens for normal component styling. Installing the first registry item writes six audio tokens to the project CSS. Each token also has a -foreground counterpart for text, and the token names are available as Tailwind colors.

TokenPurpose
--meter-okNormal level zone
--meter-warnWarning level zone
--meter-clipClip zone and clip light
--channel-mutePressed mute state
--channel-soloPressed solo state
--channel-monitorPressed monitor state

Override an Audio Token

:root {
  --meter-ok: oklch(0.72 0.12 200);
}
.dark {
  --meter-ok: oklch(0.78 0.12 200);
}

Alternatives and Related Resources

audiocn

audiocn

Open source audio UI for React: accessible mixers, meters, faders, knobs, visualizers, players, hooks, and shadcn registry components.

Leave a Reply

Your email address will not be published. Required fields are marked *