Tone.js/test/helper/Offline.js

22 lines
566 B
JavaScript
Raw Normal View History

2017-02-19 20:32:00 +00:00
define(["Tone/core/Tone", "Tone/core/Offline", "helper/BufferTest", "Tone/core/Master"],
function (Tone, Offline, BufferTest, Master) {
2015-08-16 18:23:40 +00:00
2017-02-19 16:52:33 +00:00
return function(callback, duration, channels){
2017-02-19 20:32:00 +00:00
duration = duration || 0.1;
2015-08-21 21:03:14 +00:00
channels = channels || 1;
2017-02-19 16:52:33 +00:00
return Offline(function(Transport){
2017-02-19 20:32:00 +00:00
var testFn = callback(Transport);
if (testFn){
Transport.context.on("tick", function(){
testFn(Transport.now());
});
}
2017-02-19 16:52:33 +00:00
}, duration).then(function(buffer){
2017-02-20 03:50:39 +00:00
BufferTest(buffer);
2017-02-19 16:52:33 +00:00
if (channels === 1){
buffer.toMono();
}
2017-02-19 20:32:00 +00:00
return buffer;
2017-02-19 16:52:33 +00:00
});
2015-08-16 18:23:40 +00:00
};
});