Skip to content

Instantly share code, notes, and snippets.

@katspaugh
Last active February 2, 2024 15:23
Show Gist options
  • Save katspaugh/3fbd8d8b4b6c26435f312d5e9e09a07c to your computer and use it in GitHub Desktop.
Save katspaugh/3fbd8d8b4b6c26435f312d5e9e09a07c to your computer and use it in GitHub Desktop.
// Dual waveform
import WaveSurfer from 'wavesurfer.js'
const wavesurfer = WaveSurfer.create({
container: document.body,
url: '/examples/audio/demo.wav',
height: 50,
})
wavesurfer.on('ready', () => {
const zoomedWavesurfer = WaveSurfer.create({
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
container: document.body,
media: wavesurfer.getMediaElement(),
peaks: wavesurfer.exportPeaks(),
duration: wavesurfer.getDuration(),
minPxPerSec: 200,
})
zoomedWavesurfer.on('click', () => {
zoomedWavesurfer.play()
})
})
wavesurfer.on('click', () => {
wavesurfer.play()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment