Giter Club home page Giter Club logo

node-wav-file-info's Introduction

WAV File Info for Node.JS

A lightweight module that parses WAV information data from a wav file into a Javascript Object. Basically retrieves file and header meta data information from a WAV file.

Used for:

  • Determining the validity of a .wav file
  • Detecting the bit depth / bit rate / bits per sample of a .wav file
  • Detecting the Sample Rate of a .wav file
  • Detecting the number of channels in a .wav file
  • Retrieving the file information, including file size, created date etc

Usage

npm install wav-file-info --save
var wavFileInfo = require('wav-file-info');

wavFileInfo.infoByFilename('./test.wav', function(err, info){
  if (err) throw err;
  console.log(info);
});

if err is not null, the WAV file is valid.

From the command line you can run:

node wfi.js <filename>

Result

{ header:
   { riff_head: 'RIFF',
     chunk_size: 1697504,
     wave_identifier: 'WAVE',
     fmt_identifier: 'fmt ',
     subchunk_size: 16,
     audio_format: 1,
     num_channels: 2,
     sample_rate: 44100,
     byte_rate: 45328,
     block_align: 4,
     bits_per_sample: 16,
     data_identifier: 'PAD ' },
  stats:
   { dev: 16777220,
     mode: 33184,
     nlink: 1,
     uid: 501,
     gid: 20,
     rdev: 0,
     blksize: 4096,
     ino: 71128242,
     size: 1697512,
     blocks: 3320,
     atime: Sun Nov 29 2015 10:13:15 GMT-0700 (MST),
     mtime: Sat May 23 2015 12:45:00 GMT-0600 (MDT),
     ctime: Thu Nov 12 2015 14:31:37 GMT-0700 (MST),
     birthtime: Sat May 23 2015 12:44:55 GMT-0600 (MDT)
  },
  duration: 9.623038548752834
}

Example errors

{ error: true,
  invalid_reasons:
   [ 'Expected "RIFF" string at 0',
     'Expected "WAVE" string at 4',
     'Expected "fmt " string at 8',
     'Unknwon format: 25711',
     'chunk_size does not match file size' ] }

Duration is in seconds. Stats come from Node raw fs.statSync() result.

References: http://soundfile.sapp.org/doc/WaveFormat/

TODO: Deep scan [avg amplitude, max amplitude], fork for AIFF

node-wav-file-info's People

Contributors

drj-io avatar geoffreyfloyd avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.