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-modelis 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 givesrc. Withsrc, the browser fetches the file and decodes it after mount, and the bars fill in then. The server renders no bars. Computepeakson your server for a long file, because decoding a long file in the browser is slow and uses memory. barsis the number of bars (default 64). A longerpeakslist 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.
labelnames it.valueTextwrites the position for a screen reader, for example1:05(default: a percent). seekfires when the person moves the position. It does not fire when you changev-modelfrom your code, so a playing clock can drive the bars without a loop.errorfires whensrccannot be read.loadPeaks,peaksFromChannel, anddownsampleare exported.
Usage
ts
import { BlessWaveform } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
peaks | number[] | — | loudness per slice, 0 to 1. Compute them on your server for a long file. |
src | string | — | an audio URL to decode in the browser when you have no `peaks` |
bars | number | 64 | bars drawn |
height | number | 48 | |
label | string | "Seek" | names the seek control |
valueText | ((position: number) => string) | — | text for the position, for example `(p) => "1:05"`. Default: a percent. |
disabled | boolean | — | |
modelValue | number | 0 | the position from 0 (start) to 1 (end) |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: number] | |
error | [error: unknown] | |
seek | [position: number] |