Skip to content

Instantly share code, notes, and snippets.

@katspaugh
Created May 11, 2024 13:33
Show Gist options
  • Save katspaugh/d5da9feca7995cd70caabe1ce6ec18d4 to your computer and use it in GitHub Desktop.
Save katspaugh/d5da9feca7995cd70caabe1ce6ec18d4 to your computer and use it in GitHub Desktop.
// Huge randomized peaks array
import WaveSurfer from 'wavesurfer.js'
const peaks = Array.from({ length: 1000000 }, (_, i) => Math.sin(i * Math.random() * 0.01))
const wavesurfer = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
barWidth: 10,
barRadius: 10,
barGap: 2,
url: '/examples/audio/demo.wav',
minPxPerSec: 1,
peaks,
duration: 3 * 60 * 60 * 1000,
})
wavesurfer.on('interaction', () => {
wavesurfer.play()
})
wavesurfer.on('finish', () => {
wavesurfer.setTime(0)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment