Tone.js/test/helper/Meter.js

20 lines
478 B
JavaScript
Raw Normal View History

import Offline from "helper/Offline";
2015-08-24 15:13:35 +00:00
export default function(callback, duration, channels){
return Offline(callback, duration, channels).then(function(buffer){
var rms = buffer.getRMS(512);
rms.forEach = function(callback){
for (var i = 0; i < rms.length; i++){
var level = rms[i];
callback(level, i * buffer.sampleTime);
}
};
rms.getValueAtTime = function(time){
return rms[Math.floor(time * buffer.context.sampleRate)];
};
return rms;
});
}
2015-08-24 15:13:35 +00:00