Tone.js/test/helper/OutputAudioStereo.js

33 lines
802 B
JavaScript
Raw Normal View History

2015-08-21 21:03:48 +00:00
define(["helper/Offline"], function (Offline) {
var OutputAudioStereo = function(before, after){
var duration = 0.5;
var offline = new Offline(duration, 2);
var audioLeft = false;
var audioRight = false;
offline.before(function(dest){
before(dest);
});
offline.after(function(){
if (!(audioLeft && audioRight)){
throw new Error("node outputs silence");
} else if (!audioLeft){
throw new Error("node outputs silence in left channel");
} else if (!audioRight){
throw new Error("node outputs silence in right channel");
}
after();
});
2015-08-24 15:13:56 +00:00
offline.test(function(samples){
if (Math.abs(samples[0]) > 0.01){
2015-08-21 21:03:48 +00:00
audioLeft = true;
}
2015-08-24 15:13:56 +00:00
if (Math.abs(samples[1]) > 0.01){
2015-08-21 21:03:48 +00:00
audioRight = true;
}
});
offline.run();
};
return OutputAudioStereo;
});