gibberish-dsp
Version:
Gibberish is designed to be an optimized API for audio synthesis using per-sample techniques.
28 lines (21 loc) • 531 B
JavaScript
module.exports = function( Gibberish ) {
const Time = {
bpm: 120,
export: function(target) {
Object.assign( target, Time )
},
ms : function(val) {
return val * Gibberish.ctx.sampleRate / 1000;
},
seconds : function(val) {
return val * Gibberish.ctx.sampleRate;
},
beats : function(val) {
return function() {
var samplesPerBeat = Gibberish.ctx.sampleRate / ( Gibberish.Time.bpm / 60 ) ;
return samplesPerBeat * val ;
}
}
}
return Time
}