Generate stunning audio waveforms Svelte and Canvas. Transform an array of peak data into beautifully rendered, customizable waveforms for music players, podcasts, audio editing tools, and more.
npm install svelte-audio-waveformThe fastest way to add stunning audio visualizations to your Svelte apps. Create beautiful, responsive waveform visualizations from audio files with progress indication and customizable styling. Perfect when you need professional-looking audio visualization without the complexity of heavyweight solutions like Wavesurfer.
---
Install the package using npm:
``bash`
npm install svelte-audio-waveform
---
---
`svelte
position={position}
/>
`
---
`svelte`
position={0.5}
/>
---
`svelte`
position={0.5}
barWidth={2}
/>
---
`svelte`
position={0.5}
color="#444444"
progressColor="#ff0000"
/>
---
`svelte`
position={0.5}
gradientColors={["red", "blue", "green"]}
progressGradientColors={["yellow", "orange", "purple"]}
/>
---
This example shows how to load an audio file, generate peaks, calculate playback progress, and display a waveform with playback controls.
`svelte
{#if peaks.length > 0}
---
API Reference
$3
| Prop | Type | Default | Description |
|-----------------------|---------------------|-------------------|-----------------------------------------------------|
|
peaks | number[] | required | Array of audio peak values |
| position | number | required | Current playback position as a percentage (0 to 1) |
| color | string | 'grey' | Waveform base color |
| progressColor | string | 'purple' | Progress color |
| gradientColors | string[] | undefined | Colors for gradient styling |
| progressGradientColors | string[] | undefined | Gradient colors for the progress bar |
| height | number | required | Height of the waveform |
| width | number | required | Width of the waveform |
| barWidth | number | undefined | Width of bars (if using bar mode) |---
Utilities (Optional)
This package does not include utility functions like
getPeaks, createAudioBuffer, or formatTime`. However, you can copy these utilities from the source repository if needed.---
- Inspired by Wavesurfer.js and https://github.com/SoundstripeEngineering/react-audio-waveform
- Built with Svelte and TypeScript
- Sponsored by: Generative Ambient Music DAW for Content Creators - Atmoscapia