Skip to Content
npm i @clxrity/react-audio

Spectrogram

The <Spectrogram /> component visualizes the frequency spectrum of an audio file over time.


"use client"; import { Spectrogram } from "@clxrityy/react-audio"; export default function Example() { return <Spectrogram src="/audio/drums_2.wav" width={600} height={200} />; };

Click the box below to interact with the spectrogram.



Props



PropertyTypeDescriptionRequiredDefault Value
srcstringThe source URL of the audio file to visualize.✅undefined
fftSizenumberThe size of the FFT (Fast Fourier Transform) used for audio analysis.❌1024
widthnumber | stringThe width of the spectrogram display.❌100%
heightnumber | stringThe height of the spectrogram display.❌25%
minDecibelsnumberThe minimum decibel level for the spectrogram display.❌-100
maxDecibelsnumberThe maximum decibel level for the spectrogram display.❌-25
colorMapstring[]An array of colors to use for the spectrogram visualization.❌#111,#ff0000,#ffff00,#ffffff
smoothingTimeConstantnumberThe smoothing time constant for the analyser node.❌0.8
onFrameUpdate(data: Uint8Array) => voidCallback function to handle frame updates with audio data.❌undefined
loopbooleanWhether to loop the audio playback.❌false
fillStylestringThe fill style for the spectrogram canvas.❌undefined
Last updated on

Spectrogram