plucky
v0.1.1
Published
compose musical callbacks into plucky arrangements
Downloads
2
Readme
plucky
compose musical callbacks into plucky arrangements
example
var baudio = require('baudio');
var b = baudio({ rate : 44100 });
var tau = 2 * Math.PI;
var player = require('plucky');
var music = [
function (t, clip) {
if (t > 1 / 4) clip.end();
return Math.sin(tau * 200 * t);
},
function (t, clip) {
if (t > 1 / 4) clip.end();
return Math.sin(tau * t * 200 * Math.pow(2, 1/3));
},
function (t, clip) {
if (t > 1 / 2) clip.go(0);
return Math.sin(tau * t * 100)
+ Math.sin(tau * t * 105) / 8
;
}
];
b.push(player(music));
b.play();
methods
var plucky = require('plucky')
var f = plucky(music, end)
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.
clip.next()
Trigger the next musical function, if there is one.
clip.end()
End the currently playing musical function.
clip.go(index)
Trigger the musical function at an index
in the musical array.
install
With npm do:
npm install plucky
license
MIT