Awesome
mic-stream
Get a stream of audio data from the microphone.
Unmaintained
This module is old and doesn't seem to work any longer, and I don't have capacity / interest in maintaining it. Please consider using node-record-lpcm16 instead.
wip disclaimer
Still TODO: browser support (see #9)! microphone-stream ought to do the trick.
support
Node | Browser | |
---|---|---|
Windows | NO | NO |
Linux | YES¹ | NO |
macOS | YES² | NO |
*BSD | NO | NO |
¹ requires alsa-utils
to be installed.
² requires rec
from sox to be installed.
Like to see your platform supported? Take a look at the source and consider submitting a PR!
example
Let's pipe our microphone input back to our speakers: feedback loop!
var mic = require('mic-stream')
var speaker = require('audio-speaker')
mic().pipe(speaker())
api
var mic = require('mic-stream')
var stream = mic(format={})
Creates a new audio-through stream from the local microphone. If on the browser, the user may be first asked for permission.
format
is an object that decides the format of the audio data received. It
takes a wide variety of parameters. These are defaults:
{
signed: true,
float: false,
bitDepth: 16,
byteOrder: 'LE', // or BE, if you're on a big-endian system
channels: 2,
sampleRate: 44100,
interleaved: false,
samplesPerFrame: 44100,
sampleSize: 2,
id: 'S_16_LE_2_44100_I',
max: 32678,
min: -32768
}
The returned stream
can be treated like a regular Node stream and piped
where ever you'd like.
stream.stop(cb)
Stops the microphone stream. cb
is called when the process is fully stopped.
install
With npm
, run
npm install mic-stream
For browser use you'll need a tool like browserify.
Node users will need a working install of sox.
license
ISC
works well with..
audio-speaker - Pipe audio data straight to your speaker. Works in Node and the browser!
goertzel-stream - Detect specific frequencies from a stream of audio data.