Home

Awesome

WavAudioEncoder.js

What is it?

WavAudioEncoder.js is a small JavaScript library that encodes audio data to Waveform Audio (.wav) on web browsers.

Acknowledgement

Basic idea is taken from Recorderjs (https://github.com/mattdiamond/Recorderjs). API has been totally re-designed and simplified. Now it has been a lower layer part of WebAudioRecorder.js.

Demo

https://higuma.github.io/wav-audio-encoder-js/

Library files

lib/ contains library files.

Using library

You can use it from both HTML and Web Worker.

API

encoder = new WavAudioEncoder(sampleRate, numChannels)

Create an encoder object.

In current implementation, bit width is fixed to 16 (2 bytes).

encoder.encode(buffers)

Encode audio buffers.

buffers must be an array of Float32Array audio data (range = [-1, 1]). Array length must be same as number of channels. It supports stream (incremental) processing. Sample buffers are processed to .wav fragment and appended to internal data.

blob = encoder.finish([mimeType])

Finish encoding and get Waveform Audio as a Blob.

After calling .finish(), all internal data is cleared. You must create a new encoder object to encode another audio data.

encoder.cancel()

Cancel encoding and clear all internal data.

License

MIT (see LICENSE.txt).