1.0.6 • Published 4 years ago

@pomle/audio-ident v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

audio-ident

Ultrafast zero-dependency JavaScript library for identifying WAVE and FLAC files in the browser.

Useful when you expect a user to upload big WAVE or FLAC files and want to ensure they comply with a specific format before the user have started sending data to your server.

Usage

  1. Install
npm install @pomle/audio-ident
  1. Import
import { identifyFile } from "@pomle/audio-ident";
  1. Call identifyFile with a File object from a DragEvent for example.
const handleDrop = async event => {
  event.preventDefault();
  const files = event.dataTransfer.files;
  for (const file of files) {
    const fileInfo = await identifyFile(file);
    console.log(fileInfo);
  }
}

fileInfo will contain an object like the following.

{
  type: "WAVE", 
  format: 1, /* A WAVE file may use compression. Format contains 1 if PCM (Uncompressed). */
  sampleRate: 44100, 
  channels: 2, 
  bitDepth: 16
}

Examples

Vanilla JS

1.0.6

4 years ago

1.0.5

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago