node-cubeb
This is a node.js native binding module to the cross-platform audio library cubeb.
The purpose of this module is to allow you to write to the user's soundcard.
Installation
You need to install cubeb in order for node-cubeb to work. Refer to directions provided in cubeb on how to do that.
IMPORTANT:
If you're on Linux, make sure that you have /usr/local/lib
in your library path.
After installing cubeb, installing node-cubeb works like installing any other library in npm:
$ npm install cubeb
Usage
cubeb is quite a low level library, so that applies to node-cubeb as well. cubeb has two main concepts, contexts and streams. Ideally, you should use one context per program, while the context can have multiple streams. In order to setup a basic example of playing back pure noise, you would do as follows:
var CUBEB = var SAMPLE_FORMAT = CUBEBSAMPLE_INT16LEvar CHANNEL_COUNT = 1var SAMPLE_RATE = 44100var BUFFER_SIZE = 4096var PLAY_TIME = 4000var LATENCY = 250var CTX_NAME = "my cubeb context"var STREAM_NAME = "noisy stream" { /* here you can report the state */} { /* int16 is 2 bytes, doh */ stream /* releases used buffers */ stream /* note that we get the noise for free because node buffers aren't initialized to zero. */} var ctx = CTX_NAMEvar stream = ctx STREAM_NAME SAMPLE_FORMAT CHANNEL_COUNT SAMPLE_RATE BUFFER_SIZE LATENCY datacb statecb streamstart