This is a node.js native binding module to the cross-platform audio library <a href="https://github.com/kinetiknz/cubeb">cubeb</a>.
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.
You need to install cubeb in order for node-cubeb to work. Refer to directions provided in cubeb on how to do that.
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
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 = require'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 */streamwriteframeCount * 2/* releases used buffers */streamrelease/*note that we get the noise for free becausenode buffers aren't initialized to zero.*/var ctx = CTX_NAMEvar stream =ctxSTREAM_NAMESAMPLE_FORMATCHANNEL_COUNTSAMPLE_RATEBUFFER_SIZELATENCYdatacbstatecbstreamstart