Skip to content
Calm motion: animations on this site only fade, with no movement

Waveform ​

Audio peaks that you click or key to seek

The shape of a sound as bars, and a way to move through it. Use it for a voice note, a podcast, or a track list where the position matters. It draws the bars and takes the position. It does not play sound. Pair it with an <audio> element or with AudioPlayer.

Basic
1:05 of 3:05
  • v-model is the position from 0 to 1. The played bars take the accent color, because color means chosen. The rest stay gray.
  • Give peaks (0 to 1 for each slice) or give src. With src, the browser fetches the file and decodes it after mount, and the bars fill in then. The server renders no bars. Compute peaks on your server for a long file, because decoding a long file in the browser is slow and uses memory.
  • bars is the number of bars (default 64). A longer peaks list is cut to this number, and each bar shows the loudest value of its slice.
  • A native range lies over the bars, so a click, a drag, a touch, and the arrow keys all seek. label names it. valueText writes the position for a screen reader, for example 1:05 (default: a percent).
  • seek fires when the person moves the position. It does not fire when you change v-model from your code, so a playing clock can drive the bars without a loop. error fires when src cannot be read.
  • loadPeaks, peaksFromChannel, and downsample are exported.

Usage ​

ts
import { BlessWaveform } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
peaksnumber[]—loudness per slice, 0 to 1. Compute them on your server for a long file.
srcstring—an audio URL to decode in the browser when you have no `peaks`
barsnumber64bars drawn
heightnumber48
labelstring"Seek"names the seek control
valueText((position: number) => string)—text for the position, for example `(p) => "1:05"`. Default: a percent.
disabledboolean—
modelValuenumber0the position from 0 (start) to 1 (end)

Events

NamePayloadDescription
update:modelValue[value: number]
error[error: unknown]
seek[position: number]

Released under the MIT License. Character names and artwork belong to their owners.