npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-bwf-wav-file-reader

v1.0.4

Published

Lightweight Node.js BWF and WAV file reader

Downloads

176

Readme

BWF and WAV File Reader for Node.JS

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

Used for:

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

Usage

npm install node-bwf-wav-file-reader --save
# or
yarn install node-bwf-wav-file-reader

Node Synchronous

const { read: readBwf } = require('node-bwf-wav-file-reader');

readBwf('./__tests__/audio.bwf', function (err, info) {
  if (err) console.error(err, info);
  else console.log(info);
});

Node Asynchronous

const { readSync: readSyncBwf } = require('node-bwf-wav-file-reader');

(async () => {
  const info = await readSyncBwf('./__tests__/audio.bwf');
  console.log(info);
})();

Typescript Synchronous

import * as bwfWavFileReader from 'node-bwf-wav-file-reader';

bwfWavFileReader.read('./__tests__/audio.bwf', function (err, info) {
  if (err) console.error(err, info);
  else console.log(info);
});

Typescript Asynchronous

import * as bwfWavFileReader from 'node-bwf-wav-file-reader';

(async () => {
  const info = await bwfWavFileReader.readSync('./__tests__/audio.bwf');

  console.log(info);
})();

Result

{ duration: 27.391986111111112,
  result:
   { chunkId: 'RIFF',
     chunkSize: 15777784,
     format: 'WAVE',
     subChunkFormatId: 'fmt ',
     subChunkFormatSize: 16,
     audioFormat: 1,
     numChannels: 2,
     sampleRate: 96000,
     byteRate: 576000,
     blockAlign: 6,
     bitsPerSample: 24,
     subChunkListId: 'LIST',
     subChunkListSize: 148,
     subChunkInfoId: 'INFO',
     subChunkInamId: 'INAM',
     subChunkInamSize: 64,
     subChunkInamData: 'mySession',
     subChunkIsftId: 'ISFT',
     subChunkIsftSize: 32,
     subChunkIsftData: 'myDevice',
     subChunkIartId: 'IART',
     subChunkIartSize: 24,
     subChunkIartData: '0000CC089DC40A2',
     subChunkBextId: 'bext',
     subChunkBextSize: 668,
     Description: 'mySession|0000CC089DC40A24|400',
     Originator: 'myDevice',
     OriginatorReference: 'CNCMECC089DC40A24155730911358306',
     OriginationDate: '2019-03-22',
     OriginationTime: '15:57:30',
     TimeReferenceLow: 3281795072,
     TimeReferenceHigh: 0,
     Version: 2,
     UMID: '',
     LoudnessValue: 0,
     LoudnessRange: 0,
     MaxTruePeakLevel: 0,
     MaxMomentaryLoudness: 0,
     MaxShortTermLoudness: 0 },
  stats:
   Stats {
     dev: 16777220,
     mode: 33188,
     nlink: 1,
     uid: 501,
     gid: 20,
     rdev: 0,
     blksize: 4096,
     ino: 8644128473,
     size: 15777792,
     blocks: 30816,
     atimeMs: 1554189495295.2056,
     mtimeMs: 1553863606437.2336,
     ctimeMs: 1554189504022.6528,
     birthtimeMs: 1553863606313.1821,
     atime: 2019-04-02T07:18:15.295Z,
     mtime: 2019-03-29T12:46:46.437Z,
     ctime: 2019-04-02T07:18:24.023Z,
     birthtime: 2019-03-29T12:46:46.313Z } }

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

Errors

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

{ 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' ] }

Command line usage

From the command line you can run:

node bwfr.js ./__tests__/audio.bwf

TODO

  • need to support different version of BWF to display correctly the coding history

Thanks

Contribute

  • reach me :-)
  • Or submit a PR
npm test
npm version patch
npm publish

Who am I

Martin RATINAUD FullStack Developer, creator of

  • Staking Crypto - A free tool to compare staking crypto rates upon crypto exchanges
  • Headlinker - A community of Headhunters
  • Remote Family - A free tool to find your sweet spot on earth based on your passions

Find me on LinkedIn