audio-type

Detect the audio type of a Buffer/Uint8Array

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
audio-type
2011.0.26 years ago8 years agoMinified + gzip package size for audio-type in KB

Readme

Stories in Ready
audio-type Build Status
Detect the audio type of a Buffer/Uint8Array

Install

$ npm install --save audio-type

$ bower install --save audio-type

$ component install hemanth/audio-type

Usage

Node.js
var readChunk = require('read-chunk'); // npm install read-chunk
var audioType = require('audio-type');
var buffer = readChunk.sync('meow.wav', 0, 12);

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

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

xhr.send();

API

audioType(buffer)

Returns: mp3, oga, flac, wav, m4a, false

buffer

Type: buffer (Node.js), uint8array
It only needs the first 12 bytes.

CLI

$ npm install --global audio-type

$ audio-type --help

Usage
  $ cat <filename> | audio-type
  $ audio-type <filename>

Example
  $ cat meow.mp3 | audio-type
  mp3

License

MIT © Hemanth.HM