Tone.js/test/helper/PassAudioStereo.js

29 lines
726 B
JavaScript
Raw Normal View History

2017-02-20 03:50:39 +00:00
define(["Test", "helper/Offline", "Tone/signal/Signal", "Tone/core/Master"],
function (Test, Offline, Signal, Master) {
2015-08-26 14:01:51 +00:00
2017-02-20 01:49:47 +00:00
var PassAudioStereo = function(before){
var duration = 0.2;
return Offline(function(){
var sig = new Signal(0);
before(sig);
sig.setValueAtTime(1, duration / 2);
2017-02-20 03:50:39 +00:00
}, duration, 2).then(function(buffer){
2017-02-20 01:49:47 +00:00
var silent = true;
2017-02-20 03:50:39 +00:00
buffer.forEach(function(l, r, time){
2017-02-20 01:49:47 +00:00
if (time >= duration / 2 && l !== 0 && r !== 0){
silent = false;
return;
} else if (time < duration / 2) {
expect(l).to.be.closeTo(0, 0.001);
expect(r).to.be.closeTo(0, 0.001);
2015-08-26 14:01:51 +00:00
}
2017-02-20 01:49:47 +00:00
});
if (silent){
throw new Error("node outputs silence");
2015-08-26 14:01:51 +00:00
}
});
};
return PassAudioStereo;
});