2017-08-27 21:50:31 +00:00
|
|
|
define(["Tone/component/Panner", "helper/Basic", "helper/Offline", "Test", "Tone/signal/Signal",
|
2017-10-26 04:48:51 +00:00
|
|
|
"helper/PassAudio", "helper/PassAudioStereo", "Tone/component/Merge", "Tone/core/Tone", "Tone/core/AudioNode"],
|
|
|
|
function (Panner, Basic, Offline, Test, Signal, PassAudio, PassAudioStereo, Merge, Tone, AudioNode) {
|
2016-03-04 23:59:31 +00:00
|
|
|
|
2015-08-28 22:42:44 +00:00
|
|
|
describe("Panner", function(){
|
|
|
|
|
|
|
|
Basic(Panner);
|
|
|
|
|
|
|
|
context("Panning", function(){
|
|
|
|
|
2017-04-30 18:12:07 +00:00
|
|
|
|
|
|
|
it("handles input and output connections", function(){
|
|
|
|
var panner = new Panner();
|
|
|
|
Test.connect(panner);
|
|
|
|
panner.connect(Test);
|
|
|
|
panner.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can be constructed with the panning value", function(){
|
|
|
|
var panner = new Panner(0.3);
|
|
|
|
expect(panner.pan.value).to.be.closeTo(0.3, 0.001);
|
|
|
|
panner.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("passes the incoming signal through", function(){
|
|
|
|
return PassAudio(function(input){
|
|
|
|
var panner = new Panner().toMaster();
|
|
|
|
input.connect(panner);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("passes the incoming stereo signal through", function(){
|
|
|
|
return PassAudioStereo(function(input){
|
|
|
|
var panner = new Panner().toMaster();
|
|
|
|
input.connect(panner);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("pans hard left when the pan is set to -1", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var panner = new Panner(-1).toMaster();
|
2017-10-26 04:07:02 +00:00
|
|
|
new Signal(1).connect(panner);
|
2017-04-30 18:12:07 +00:00
|
|
|
}, 0.1, 2).then(function(buffer){
|
|
|
|
buffer.forEach(function(l, r){
|
|
|
|
expect(l).to.be.closeTo(1, 0.01);
|
|
|
|
expect(r).to.be.closeTo(0, 0.01);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("pans hard right when the pan is set to 1", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var panner = new Panner(1).toMaster();
|
2017-10-26 04:07:02 +00:00
|
|
|
new Signal(1).connect(panner);
|
2017-04-30 18:12:07 +00:00
|
|
|
}, 0.1, 2).then(function(buffer){
|
|
|
|
buffer.forEach(function(l, r){
|
|
|
|
expect(l).to.be.closeTo(0, 0.01);
|
|
|
|
expect(r).to.be.closeTo(1, 0.01);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-26 04:07:02 +00:00
|
|
|
it("mixes the signal in equal power when panned center", function(){
|
2017-02-20 04:55:55 +00:00
|
|
|
return Offline(function(){
|
2017-10-26 04:07:02 +00:00
|
|
|
var panner = new Panner(0).toMaster();
|
|
|
|
new Signal(1).connect(panner);
|
2017-02-20 04:55:55 +00:00
|
|
|
}, 0.1, 2).then(function(buffer){
|
|
|
|
buffer.forEach(function(l, r){
|
2017-10-26 04:07:02 +00:00
|
|
|
expect(l).to.be.closeTo(0.707, 0.01);
|
|
|
|
expect(r).to.be.closeTo(0.707, 0.01);
|
2017-02-20 04:55:55 +00:00
|
|
|
});
|
|
|
|
});
|
2015-08-28 22:42:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-08-27 21:50:31 +00:00
|
|
|
});
|