Tone.js/test/helper/OutputAudio.js
2015-08-21 17:03:48 -04:00

25 lines
No EOL
520 B
JavaScript

define(["helper/Offline", "Test"], function (Offline, Test) {
var OutputAudio = function(before, after){
var duration = 0.5;
var offline = new Offline(duration, 1);
var passedAudio = false;
offline.before(function(dest){
before(dest);
});
offline.after(function(){
if (!passedAudio){
throw new Error("node outputs silence");
}
after();
});
offline.test(function(sample){
if (Math.abs(sample) > 0.01){
passedAudio = true;
}
});
offline.run();
};
return OutputAudio;
});