mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-29 04:53:10 +00:00
33 lines
No EOL
802 B
JavaScript
33 lines
No EOL
802 B
JavaScript
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();
|
|
});
|
|
offline.test(function(samples){
|
|
if (Math.abs(samples[0]) > 0.01){
|
|
audioLeft = true;
|
|
}
|
|
if (Math.abs(samples[1]) > 0.01){
|
|
audioRight = true;
|
|
}
|
|
});
|
|
offline.run();
|
|
};
|
|
|
|
return OutputAudioStereo;
|
|
}); |