Tone.js/test/helper/OutputAudio.js

25 lines
520 B
JavaScript
Raw Normal View History

2015-08-21 21:03:48 +00:00
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;
});