wavesurfer.js

Navigable waveform built on Web Audio and Canvas

Github星跟踪图

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

Wavesurfer can be used 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
});

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.

主要指标

概览
名称与所有者katspaugh/wavesurfer.js
主编程语言TypeScript
编程语言JavaScript (语言数: 4)
平台
许可证BSD 3-Clause "New" or "Revised" License
所有者活动
创建于2012-03-04 14:38:02
推送于2025-05-28 20:13:58
最后一次提交
发布数255
最新版本名称7.9.5 (发布于 )
第一版名称0.0.1 (发布于 2013-12-16 18:47:08)
用户参与
星数9.4k
关注者数167
派生数1.7k
提交数2k
已启用问题?
问题数2184
打开的问题数44
拉请求数1019
打开的拉请求数4
关闭的拉请求数176
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?