useWaveformData
Decode an audio file and reduce it to cached waveform peaks.
$ pnpm dlx shadcn@latest add @audiocn/use-waveform-dataUsage
const { peaks, duration, status } = useWaveformData("/episode.mp3", {
samples: 800,
});
<Waveform loading={status === "loading"} peaks={peaks} duration={duration} />;Peaks are the loudest sample in each slice, normalised so the loudest slice is
- Results are cached per file and sample count.
srccan also be anAudioBuffer.
Options
Prop
Type
Returns
Prop
Type
computePeaks(buffer, samples) is exported for use outside React.