Socket
Socket
Sign inDemoInstall

audio-type

Package Overview
Dependencies
0
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    audio-type

Detect the audio type of a Buffer/Uint8Array


Version published
Maintainers
3
Install size
4.97 kB
Created

Readme

Source

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 •

Keywords

FAQs

Last updated on 03 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc