lbmrn-pcm-utils

PCM audio utilities for Node.js

Features
-
Interleaving/deinterleaving - Unzip interleaved PCM data into separate channel streams and vice-versa.
-
Mixing - Mix 2 or more PCM channels into one.
-
Format conversion - Transform a stream from one PCM format to another (ie. float to int).
-
Evented - Doesn't block the main loop, thanks to uv_queue_work
.
-
Streams2 compatible - Everything's just a pipeable stream.
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'),
channels = 2,
format = pcmUtils.FMT_F32LE,
unzipper = new pcmUtils.Unzipper(channels, format),
zipper = new pcmUtils.Zipper(channels, format),
mixer = new pcmUtils.Mixer(channels, format),
formatter = new pcmUtils.Formatter(format, pcmUtils.FMT_S16LE);
process.stdin.pipe(unzipper);
unzipper.left.pipe(zipper.left);
unzipper.right.pipe(zipper.right);
zipper.pipe(process.stdout);
unzipper.left.pipe(mixer.left);
unzipper.right.pipe(mixer.right);
mixer.pipe(process.stderr);
var fs = require('fs'),
outFileStream = fs.createWriteStream('/tmp/s16le.pcm');
formatter.pipe(outFileStream);
mixer.pipe(formatter);
License
MIT