2018-02-05 03:59:17 +00:00
|
|
|
define(["helper/Offline"], function(Offline) {
|
2015-08-24 15:13:35 +00:00
|
|
|
|
2017-02-20 21:45:32 +00:00
|
|
|
return function(callback, duration, channels){
|
2015-08-24 15:13:35 +00:00
|
|
|
|
2017-02-20 21:45:32 +00:00
|
|
|
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];
|
2017-05-01 21:44:25 +00:00
|
|
|
callback(level, i * buffer.sampleTime);
|
2015-08-24 15:13:35 +00:00
|
|
|
}
|
2017-02-20 21:45:32 +00:00
|
|
|
};
|
2018-02-05 03:59:17 +00:00
|
|
|
rms.getValueAtTime = function(time){
|
|
|
|
return rms[Math.floor(time * buffer.context.sampleRate)];
|
|
|
|
};
|
2017-02-20 21:45:32 +00:00
|
|
|
return rms;
|
|
|
|
});
|
2015-08-24 15:13:35 +00:00
|
|
|
};
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|