mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 20:13:07 +00:00
ed71d8141b
no longer using AMD (require.js) style imports, and beginning to move to es6 "import/export" statements everywhere.
19 lines
478 B
JavaScript
19 lines
478 B
JavaScript
import Offline from "helper/Offline";
|
|
|
|
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;
|
|
});
|
|
}
|
|
|