JSPM

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

Detect the audio type of a Buffer/Uint8Array

Package Exports

  • audio-type

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 (audio-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 imageType = 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, 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