node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



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_RATE = 44100
var BUFFER_SIZE = 4096
var PLAY_TIME = 4000
var LATENCY = 250
var CTX_NAME = "my cubeb context"
var STREAM_NAME = "noisy stream"
function stateCallback (stateID) {
    /* here you can report the state */
function dataCallback (frameCount) {
    /* int16 is 2 bytes, doh */
    stream.write(new Buffer(frameCount * 2))
    /* releases used buffers */
     note that we get the noise for free because
     node buffers aren't initialized to zero.
var ctx = new CUBEB.Context(CTX_NAME)
var stream = new CUBEB.Stream(