2.2.1 • Published 3 years ago

audio-type v2.2.1

Weekly downloads
942
License
MIT
Repository
github
Last release
3 years ago

audio-type test stable npm license

Detect the audio type of a ArrayBuffer/Uint8Array

Install

$ npm i audio-type

Usage

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

audioType(buffer);
//=> wav
Browser
import audioType from './audio-type.js'

var xhr = new XMLHttpRequest();
xhr.open('GET', 'meow.flac');
xhr.responseType = 'arraybuffer';

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

xhr.send();

API

audioType(buffer)

Returns: 'mp3', 'oga', 'flac', 'wav', 'm4a', 'opus', 'qoa'

buffer

Type: buffer (Node.js), arrayBuffer, uint8array

It only needs the first 12 bytes.

License

MIT •

2.2.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.2

10 years ago

1.0.0

11 years ago

0.3.0

11 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago