Tone.js/test/helper/Offline.js
tambien ed71d8141b amd to es6 import/export
no longer using AMD (require.js) style imports, and beginning to move to es6 "import/export" statements everywhere.
2019-01-27 13:05:20 -05:00

26 lines
663 B
JavaScript

import Tone from "Tone/core/Tone";
import Offline from "Tone/core/Offline";
import BufferTest from "helper/BufferTest";
import Master from "Tone/core/Master";
export default function(callback, duration, channels){
duration = duration || 0.1;
channels = channels || 1;
return Offline(function(Transport){
var testFn = callback(Transport);
if (testFn && Tone.isFunction(testFn.then)){
return testFn;
} else if (Tone.isFunction(testFn)){
Transport.context.on("tick", function(){
testFn(Transport.now());
});
}
}, duration).then(function(buffer){
BufferTest(buffer);
if (channels === 1){
buffer.toMono();
}
return buffer;
});
}