JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14581
  • Score
    100M100P100Q186637F

isomorphic wav data decoder

Package Exports

  • wav-decoder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wav-decoder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

wav-decoder

Build Status NPM Version Bower License

isomorphic wav data decoder

Installation

npm:

npm install wav-decoder

bower:

bower install wav-decoder

downloads:

API

WavDecoder

  • constructor()

Instance methods

  • decode(buffer: ArrayBuffer): Promise<object>

Usage

node.js

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

var buffer = fs.readFileSync("foobar.wav");

new WavDecoder().decode(buffer).then(function(audioData) {
  console.log(audioData.numberOfChannels);
  console.log(audioData.length);
  console.log(audioData.sampleRate);
  console.log(audioData.channelData[0]); // Float32Array
  console.log(audioData.channelData[1]); // Float32Array
});

browser

<script src="/path/to/wav-decoder.js"></script>
fetch("foobar.wav").then(function(res) {
  return res.arraybuffer();
}).then(function(buffer) {
  return new WavDecoder().decode(buffer);
}).then(function(audioData) {
  console.log(audioData.numberOfChannels);
  console.log(audioData.length);
  console.log(audioData.sampleRate);
  console.log(audioData.channelData[0]); // Float32Array
  console.log(audioData.channelData[1]); // Float32Array
});

License

MIT