npm.io
1.1.2 • Published 10 years ago

is-wav

Licence
MIT
Version
1.1.2
Deps
0
Vulns
0
Weekly
0
Stars
7

is-wav Build Status

Check if a Buffer/Uint8Array is a WAV file.

Install

$ npm install --save is-wav
$ bower install --save is-wav
$ component install hemanth/is-wav

Usage

Node.js
var readChunk = require('read-chunk'); // npm install read-chunk
var isWav = require('is-wav');
var buffer = readChunk('meow.wav', 0, 12);

isWav(buffer);
//=> true
Browser
var xhr = new XMLHttpRequest();
xhr.open('GET', 'meow.wav');
xhr.responseType = 'arraybuffer';

xhr.onload = function () {
	isWav(new Uint8Array(this.response));
	//=> true
};

xhr.send();

API

isWav(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 12 bytes.

License

MIT Hemanth.HM