Last active
February 2, 2024 15:23
-
-
Save katspaugh/3fbd8d8b4b6c26435f312d5e9e09a07c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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