node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


compose musical callbacks into plucky arrangements


compose musical callbacks into plucky arrangements


var baudio = require('baudio');
var b = baudio({ rate : 44100 });
var tau = 2 * Math.PI;
var player = require('plucky');
var music = [
    function (t, clip) {
        if (> 1 / 4) clip.end();
        return Math.sin(tau * 200 * t);
    function (t, clip) {
        if (> 1 / 4) clip.end();
        return Math.sin(tau * t * 200 * Math.pow(2, 1/3));
    function (t, clip) {
        if (> 1 / 2) clip.go(0);
        return Math.sin(tau * t * 100)
            + Math.sin(tau * t * 105) / 8


var plucky = require('plucky')

Return a baudio-compatible function given an array of music functions.

Each function in the array music will be called fn(t, clip) with the relative time in seconds since it was started t and a clip object described below. Musical functions should return a floating point value between -1 and 1, inclusive.

If provided, end() fires when there's no more music to play.

Trigger the next musical function, if there is one.

If index is specified, trigger the musical function at index.

End the currently playing clip and trigger the next clip.

End the currently playing clip only.

Trigger the musical function at an index in the musical array and stop playing the current clip.


Absolute time in seconds. This is different from the t in f(t, clip), which is a relative time in seconds for the clip since it started playing.


With npm do:

npm install plucky