Skip to content
This repository has been archived by the owner. It is now read-only.
promise-based wav encoder
Branch: master
Clone or download
Latest commit c67e780 Aug 11, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test add symmetric option (#10) Aug 11, 2017
.eslintrc.json Fix float to integer (#12) Aug 8, 2017
.gitattributes Fix float to integer (#12) Aug 8, 2017
.gitignore update dev tools Dec 21, 2015
.travis.yml Fix float to integer (#12) Aug 8, 2017
README.md update README [ci skip] Aug 11, 2017
index.js add symmetric option (#10) Aug 11, 2017
package-lock.json 1.3.0 Aug 11, 2017
package.json 1.3.0 Aug 11, 2017

README.md

wav-encoder

Build Status NPM Version License

promise-based wav encoder

Installation

$ npm install wav-encoder

API

  • encode(audioData: AudioData, [opts: object]): Promise<ArrayBuffer>
    • audioData should contain two fields sampleRate and channelData.
    • opts is an optional parameter which used to design the output wav format.
      • opts.bitDepth the number of bits of information in each sample
      • opts.float encode to float values
      • opts.symmetric encode to symmetrical values (see #10)
      • The default format is { float: false, bitDepth: 16 }
  • encode.sync(audioData: AudioData, [opts: object]): ArrayBuffer
    • synchronous version
interface AudioData {
  sampleRate: number;
  channelData: Float32Array[];
}

Usage

const fs = require("fs");
const WavEncoder = require("wav-encoder");

const whiteNoise1sec = {
  sampleRate: 44100,
  channelData: [
    new Float32Array(44100).map(() => Math.random() - 0.5),
    new Float32Array(44100).map(() => Math.random() - 0.5)
  ]
};

WavEncoder.encode(whiteNoise1sec).then((buffer) => {
  fs.writeFileSync("noise.wav", new Buffer(buffer));
});

License

MIT

You can’t perform that action at this time.