Generate waveform peak data from audio files for WaveformPlayer and WaveformBar.
Pre-generated waveforms mean instant visualization — no client-side audio decoding needed.
# Run directly with npx
npx @arraypress/waveform-gen ./audio/*.mp3 --output ./waveforms/
# Or install globally
npm install -g @arraypress/waveform-gen# Generate JSON per audio file
waveform-gen ./audio/*.mp3 --output ./waveforms/
# Directory scan
waveform-gen ./audio/ --recursive --output ./waveforms/
# Custom sample count
waveform-gen ./audio/*.mp3 --output ./waveforms/ --samples 400
# Print peaks to stdout (for piping)
waveform-gen song.mp3 --format inline| Option | Default | Description |
|---|---|---|
--samples <n> |
1800 |
Number of peaks to generate |
--precision <n> |
2 |
Decimal places for rounding |
--output <dir> |
Same as input | Output directory |
--format <type> |
json |
json or inline (stdout) |
--recursive |
off | Scan directories recursively |
--quiet |
off | Suppress progress output |
{
"peaks": [
0.2,
0.37,
0.41,
0.55,
...
]
}With markers (auto-detected from sidecar file):
{
"peaks": [
0.2,
0.37,
0.41,
0.55,
...
],
"markers": [
{
"time": 0,
"label": "Intro"
},
{
"time": 30,
"label": "Chorus"
}
]
}Place a .markers.txt file alongside the audio with the same name:
# song.markers.txt
0:00 Intro
0:30 Verse 1
1:15 Chorus
1:02:30 Bridge
Supports SS, MM:SS, and H:MM:SS timestamps. Lines starting with # are ignored. Markers are auto-detected — no
flag needed.
<div data-waveform-player
data-url="song.mp3"
data-waveform="waveforms/song.json">
</div><div data-wb-play
data-url="song.mp3"
data-wb-waveform="waveforms/song.json">
</div>npm install @arraypress/waveform-genimport {generatePeaks} from '@arraypress/waveform-gen';
const {peaks} = await generatePeaks('./song.mp3', {
samples: 1800,
precision: 2
});MP3, WAV, FLAC, OGG, M4A, AAC
Node.js 18+
| Package | Description |
|---|---|
| WaveformPlayer | Core audio player with waveform visualization |
| WaveformBar | Persistent bottom-bar player with queue, favorites, cart, DJ mode |
| WaveformGen | CLI tool to pre-generate waveform JSON from audio files |
| WaveformPlaylist | Playlist and chapter support addon |
| WaveformTracker | Audio engagement analytics |
MIT © ArrayPress