1.0.2 • Published 7 years ago

mic-stream v1.0.2

Weekly downloads
14
License
-
Repository
github
Last release
7 years ago

mic-stream

Get a stream of audio data from the microphone.

wip disclaimer

Still TODO: browser support! microphone-stream ought to do the trick.

support

NodeBrowser
WindowsNONO
LinuxYES¹NO
macOSYES²NO
*BSDNONO

¹ 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.

1.0.2

7 years ago

1.0.0

7 years ago

0.1.0

8 years ago