Skip to content

Instantly share code, notes, and snippets.

import WaveSurfer from 'wavesurfer.js'
const url = '/examples/audio/demo.wav'
const cache = localStorage.getItem('cache' + url)
const wavesurfer = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
url,
import WaveSurfer from 'wavesurfer.js'
import WebAudioPlayer from 'wavesurfer.js/dist/webaudio.js'
const audio = new WebAudioPlayer()
audio.src = '/examples/audio/demo.wav'
audio.addEventListener('canplay', () => {
const wavesurfer = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
// Custom styling via CSS
/*
<html>
<style>
#waveform ::part(scroll) {
padding: 15px;
}
#waveform ::part(outside) {
import WaveSurfer from 'wavesurfer.js'
import RegionsPlugin from 'wavesurfer.js/dist/plugins/regions.esm.js'
// Initialize the Regions plugin
const regions = RegionsPlugin.create()
// Create a WaveSurfer instance
const ws = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
// Regions plugin
import WaveSurfer from 'wavesurfer.js'
import RegionsPlugin from 'wavesurfer.js/dist/plugins/regions.esm.js'
// Initialize the Regions plugin
const regions = RegionsPlugin.create()
// Create a WaveSurfer instance
const ws = WaveSurfer.create({
@katspaugh
katspaugh / panner.js
Created September 25, 2024 07:27
wavesurfer stereo panner
import WaveSurfer from 'wavesurfer.js'
const wavesurfer = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
url: '/examples/audio/stereo.mp3',
mediaControls: true,
})
// Record plugin
import WaveSurfer from 'https://unpkg.com/[email protected]/dist/wavesurfer.esm.js'
import RecordPlugin from 'https://unpkg.com/[email protected]/dist/plugins/record.esm.js'
const wavesurfer2 = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
url: '/examples/audio/audio.wav',
// Regions click through
import WaveSurfer from 'wavesurfer.js'
import RegionsPlugin from 'wavesurfer.js/dist/plugins/regions.esm.js'
// Initialize the Regions plugin
const regions = RegionsPlugin.create()
// Create a WaveSurfer instance
const wavesurfer = WaveSurfer.create({
import WaveSurfer from 'wavesurfer.js'
const wavesurfer = WaveSurfer.create({
container: document.body,
waveColor: 'rgb(200, 0, 200)',
progressColor: 'rgb(100, 0, 100)',
url: '/examples/audio/stereo.mp3',
splitChannels: true,
mediaControls: true,
})
// 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)',