wav-decoder
promise-based wav decoder
Last updated 3 years ago by mohayonao .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install wav-decoder 
SYNC missed versions from official npm registry.

wav-decoder

Build Status NPM Version License

promise-based wav decoder

Installation

$ npm install wav-decoder

API

  • decode(src: ArrayBuffer, [opts: object]): Promise<AudioData>
    • if provide an instance of Buffer, it is converted to ArrayBuffer like Uint8Array.from(src).buffer implicitly.
    • opts.symmetric decode to symmetrical values (see #14)
  • decode.sync(src: ArrayBuffer, [opts: object]): AudioData
    • synchronous version
Returns
interface AudioData {
  sampleRate: number;
  channelData: Float32Array[];
}

Usage

const fs = require("fs");
const WavDecoder = require("wav-decoder");

const readFile = (filepath) => {
  return new Promise((resolve, reject) => {
    fs.readFile(filepath, (err, buffer) => {
      if (err) {
        return reject(err);
      }
      return resolve(buffer);
    });
  });
};

readFile("foobar.wav").then((buffer) => {
  return WavDecoder.decode(buffer);
}).then(function(audioData) {
  console.log(audioData.sampleRate);
  console.log(audioData.channelData[0]); // Float32Array
  console.log(audioData.channelData[1]); // Float32Array
});

License

MIT

Current Tags

  • 1.3.0                                ...           latest (3 years ago)

11 Versions

  • 1.3.0                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 44
This Month 67
Last Day 15
Last Week 46
Last Month 112
Dependencies (0)
None
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |