2019-01-27 18:05:20 +00:00
|
|
|
import Merge from "Tone/component/Merge";
|
|
|
|
import Basic from "helper/Basic";
|
|
|
|
import PassAudio from "helper/PassAudio";
|
|
|
|
import PassAudioStereo from "helper/PassAudioStereo";
|
|
|
|
import Test from "helper/Test";
|
|
|
|
import Offline from "helper/Offline";
|
|
|
|
import Signal from "Tone/signal/Signal";
|
|
|
|
describe("Merge", function(){
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Basic(Merge);
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
context("Merging", function(){
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("handles input and output connections", function(){
|
|
|
|
var merge = new Merge();
|
|
|
|
Test.connect(merge);
|
|
|
|
merge.connect(Test);
|
|
|
|
merge.dispose();
|
|
|
|
});
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("defaults to two channels", function(){
|
|
|
|
var merge = new Merge();
|
|
|
|
expect(merge.numberOfInputs).to.equal(2);
|
|
|
|
merge.dispose();
|
|
|
|
});
|
2019-01-27 01:06:07 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can pass in more channels", function(){
|
|
|
|
var merge = new Merge(4);
|
|
|
|
expect(merge.numberOfInputs).to.equal(4);
|
|
|
|
Test.connect(merge, 0, 0);
|
|
|
|
Test.connect(merge, 0, 1);
|
|
|
|
Test.connect(merge, 0, 2);
|
|
|
|
Test.connect(merge, 0, 3);
|
|
|
|
merge.dispose();
|
|
|
|
});
|
2019-01-27 01:06:07 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("passes the incoming signal through", function(){
|
|
|
|
return PassAudio(function(input){
|
|
|
|
var merge = new Merge().toMaster();
|
|
|
|
input.connect(merge);
|
2015-08-28 22:42:44 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("merge two signal into one stereo signal", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var sigL = new Signal(1);
|
|
|
|
var sigR = new Signal(2);
|
|
|
|
var merger = new Merge();
|
|
|
|
sigL.connect(merger.left);
|
|
|
|
sigR.connect(merger.right);
|
|
|
|
merger.toMaster();
|
|
|
|
}, 0.1, 2).then(function(buffer){
|
|
|
|
buffer.forEach(function(l, r){
|
|
|
|
expect(l).to.be.closeTo(1, 0.001);
|
|
|
|
expect(r).to.be.closeTo(2, 0.001);
|
2015-08-28 22:42:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
|