The Wayback Machine - https://web.archive.org/web/20200523011938/https://github.com/katspaugh/wavesurfer.js
Skip to content
Navigable waveform built on Web Audio and Canvas
JavaScript HTML CSS
Branch: master
Clone or download

Latest commit

win-chen When splitting channels, allow coloring and filtering of channels (#1947
)

* add splitChannelsOptions param

* add splitChannelsOptions example

* add filterChannels param in splitChannelOptions

* add method to filter out channels from the waveform

* draw empty waveform if all channels have been filtered out

* add/clarify comments

* add changelog and version number to setFilteredChannels

Co-authored-by: Winnie Chen <win-chen@users.noreply.github.com>
Latest commit 5c2c392 May 18, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github docs: add OS reference to ticket template Apr 14, 2019
.vscode build: configure VS Code Debugger for dev env (#1618) Apr 15, 2019
assets Release 2.1.3 (#1558) Jan 21, 2019
build-config Add Gatsby compatibility (#1938) May 11, 2020
example When splitting channels, allow coloring and filtering of channels (#1947 May 18, 2020
spec return Promise from wavesurfer.exportPCM (#1811) Nov 27, 2019
src When splitting channels, allow coloring and filtering of channels (#1947 May 18, 2020
.babelrc bump version: 2.1.0 (#1470) Oct 1, 2018
.editorconfig Es6 (#863) Nov 23, 2016
.esdoc.json Fix #1241: Updated dependencies & refactored build config into sepera… Nov 7, 2017
.eslintrc.js lint: remove prettier and instead use eslint only Apr 7, 2020
.gitignore build: use files array in package.json to specify what files get pack… Apr 24, 2019
.htmlhintrc update dev dependencies and add prepublish command (#1274) Dec 18, 2017
.npmignore build: use files array in package.json to specify what files get pack… Apr 24, 2019
.travis.yml travis: test on ubuntu 18 and install additional audio codecs Jan 12, 2020
CHANGES.md When splitting channels, allow coloring and filtering of channels (#1947 May 18, 2020
CNAME Update CNAME Aug 6, 2015
LICENSE release v3.3.0 (#1835) Dec 30, 2019
README.md Add npm package name to readme (#1883) Mar 24, 2020
UPGRADE.md add upgrade instructions for 3.0 (#1687) Jul 9, 2019
appveyor.yml update dev dependencies: upgrade babel (#1469) Sep 28, 2018
bower.json bump version: v3.3.3 (#1916) Apr 16, 2020
karma.conf.js add MediaElementWebAudio backend: use HTML5 audio tag with Web Audio … Oct 18, 2019
package.json update dependencies May 12, 2020

README.md

wavesurfer.js

npm version npm Join the chat at https://gitter.im/katspaugh/wavesurfer.js

Interactive navigable audio visualization using Web Audio and Canvas.

Screenshot

See a tutorial and examples on wavesurfer-js.org.

Browser support

wavesurfer.js works only in modern browsers supporting Web Audio.

It will fallback to Audio Element in other browsers (without graphics). You can also try wavesurfer.swf which is a Flash-based fallback.

FAQ

Can the audio start playing before the waveform is drawn?

Yes, if you use the backend: 'MediaElement' option. See here: https://wavesurfer-js.org/example/audio-element/. The audio will start playing as you press play. A thin line will be displayed until the whole audio file is downloaded and decoded to draw the waveform.

Can drawing be done as file loads?

No. Web Audio needs the whole file to decode it in the browser. You can however load pre-decoded waveform data to draw the waveform immediately. See here: https://wavesurfer-js.org/example/audio-element/ (the "Pre-recoded Peaks" section).

API in examples

Choose a container:

<div id="waveform"></div>

Create an instance, passing the container selector and options:

var wavesurfer = WaveSurfer.create({
    container: '#waveform',
    waveColor: 'violet',
    progressColor: 'purple'
});

Subscribe to some events:

wavesurfer.on('ready', function () {
    wavesurfer.play();
});

Load an audio file from a URL:

wavesurfer.load('example/media/demo.wav');

Documentation

See the documentation on all available methods, options and events on the homepage.

Upgrade

See the upgrade document if you're upgrading from a previous version of wavesurfer.js.

Using with a module bundler

Install Wavesurfer:

npm install wavesurfer.js --save
# or
yarn add wavesurfer.js

Use it with a module system like this:

// import
import WaveSurfer from 'wavesurfer.js';

// commonjs/requirejs
var WaveSurfer = require('wavesurfer.js');

// amd
define(['WaveSurfer'], function(WaveSurfer) {
  // ... code
});

Related projects

For a list of projects using wavesurfer.js, check out the projects page.

Development

Build Status Coverage Status Size

Install development dependencies:

npm install

Development tasks automatically rebuild certain parts of the library when files are changed (start – wavesurfer, start:plugins – plugins). Start a dev task and go to localhost:8080/example/ to test the current build.

Start development server for core library:

npm run start

Start development server for plugins:

npm run start:plugins

Build all the files. (generated files are placed in the dist directory.)

npm run build

Running tests only:

npm run test

Build documentation with esdoc (generated files are placed in the doc directory.)

npm run doc

If you want to use the VS Code - Debugger for Chrome, there is already a launch.json with a properly configured sourceMapPathOverrides for you.

Editing documentation

The homepage and documentation files are maintained in the gh-pages branch. Contributions to the documentation are especially welcome.

Credits

Initial idea by Alex Khokhulin. Many thanks to the awesome contributors!

License

License

This work is licensed under a BSD 3-Clause License.

You can’t perform that action at this time.