Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

lbmrn-pcm-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lbmrn-pcm-utils

PCM audio utilities for Node.js

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

lbmrn-pcm-utils

Dependency Status devDependency Status Downloads

PCM audio utilities for Node.js

NPM

Features

Note: For sample rate conversion, check out resampler. For playback, try speaker or alsa (which also records).

Installation

Install with npm:

$ npm install --save lbmrn-pcm-utils

Usage

var pcmUtils = require('lbmrn-pcm-utils'),

  // The following variables represent the defaults for all constructors.
  channels = 2,                // 2 channels (left/right)
  format = pcmUtils.FMT_F32LE, // 32 bit little-endian float

  // Available formats: No big-endian support yet!
  //
  // pcmUtils.FMT_F32LE - 32 bit little-endian float
  // pcmUtils.FMT_F32BE - 32 bit big-endian float **Not currently supported**
  // pcmUtils.FMT_S16LE - signed 16 bit little-endian integer
  // pcmUtils.FMT_S16BE - signed 16 bit big-endian integer **Not currently supported**
  // pcmUtils.FMT_U16LE - unsigned 16 bit little-endian integer
  // pcmUtils.FMT_U16BE - unsigned 16 bit big-endian integer **Not currently supported**

  // Unzipper deinterleaves PCM data into multiple single-channel streams.
  unzipper = new pcmUtils.Unzipper(channels, format),

  // Zipper interleaves multiple single-channel PCM streams into one.
  zipper = new pcmUtils.Zipper(channels, format),
  
  // Mixer mixes multiple channels into a single channel stream.
  mixer = new pcmUtils.Mixer(channels, format),
  
  // Formatter transforms single-channel PCM data from one format to another,
  // 32 bit little-endian float to signed 16 bit little-endian integer in this case.
  formatter = new pcmUtils.Formatter(format, pcmUtils.FMT_S16LE);

// Read interleaved PCM data from stdin
process.stdin.pipe(unzipper);

// Unzip (de-interleave) it then zip it right back up to stdout
unzipper.left.pipe(zipper.left);    // or `unzipper.outputs[0].pipe(zipper.inputs[0]);`
unzipper.right.pipe(zipper.right);  // or `unzipper.outputs[1].pipe(zipper.inputs[1]);`
zipper.pipe(process.stdout);

// Mix left and right channels and pipe mono to stderr
unzipper.left.pipe(mixer.left);     // or `unzipper.outputs[0].pipe(mixer.inputs[0]);`
unzipper.right.pipe(mixer.right);   // or `unzipper.outputs[1].pipe(mixer.inputs[1]);`
mixer.pipe(process.stderr);

// Convert the mono mixer output into signed 16 bit little-endian and write to file.
var fs = require('fs'),
  outFileStream = fs.createWriteStream('/tmp/s16le.pcm');
formatter.pipe(outFileStream);
mixer.pipe(formatter);

License

MIT

Keywords

pcm

FAQs

Package last updated on 27 Oct 2016

Did you know?

Socket

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