2019-01-27 18:05:20 +00:00
|
|
|
import MidSideSplit from "Tone/component/MidSideSplit";
|
|
|
|
import MidSideMerge from "Tone/component/MidSideMerge";
|
|
|
|
import Basic from "helper/Basic";
|
|
|
|
import Signal from "Tone/signal/Signal";
|
|
|
|
import PassAudioStereo from "helper/PassAudioStereo";
|
|
|
|
import Test from "helper/Test";
|
|
|
|
import Offline from "helper/Offline";
|
|
|
|
import Merge from "Tone/component/Merge";
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
describe("MidSideSplit", function(){
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Basic(MidSideSplit);
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
context("Splitting", function(){
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("handles inputs and outputs", function(){
|
|
|
|
var split = new MidSideSplit();
|
|
|
|
Test.connect(split);
|
|
|
|
split.mid.connect(Test);
|
|
|
|
split.side.connect(Test);
|
|
|
|
split.dispose();
|
|
|
|
});
|
2015-08-28 22:42:44 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("mid is if both L and R are the same", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var split = new MidSideSplit();
|
|
|
|
split.mid.toMaster();
|
|
|
|
var merge = new Merge().connect(split);
|
|
|
|
new Signal(0.5).connect(merge.left);
|
|
|
|
new Signal(0.5).connect(merge.right);
|
|
|
|
}).then(function(buffer){
|
|
|
|
expect(buffer.min()).to.be.closeTo(0.707, 0.01);
|
|
|
|
expect(buffer.max()).to.be.closeTo(0.707, 0.01);
|
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("side is 0 if both L and R are the same", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var split = new MidSideSplit();
|
|
|
|
split.side.toMaster();
|
|
|
|
var merge = new Merge().connect(split);
|
|
|
|
new Signal(0.5).connect(merge.left);
|
|
|
|
new Signal(0.5).connect(merge.right);
|
|
|
|
}).then(function(buffer){
|
|
|
|
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
|
|
expect(buffer.max()).to.be.closeTo(0, 0.01);
|
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("mid is 0 if both L and R opposites", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var split = new MidSideSplit();
|
|
|
|
split.mid.toMaster();
|
|
|
|
var merge = new Merge().connect(split);
|
|
|
|
new Signal(-1).connect(merge.left);
|
|
|
|
new Signal(1).connect(merge.right);
|
|
|
|
}).then(function(buffer){
|
|
|
|
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
|
|
expect(buffer.max()).to.be.closeTo(0, 0.01);
|
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("can decompose and reconstruct a signal", function(){
|
|
|
|
return Offline(function(){
|
|
|
|
var midSideMerge = new MidSideMerge().toMaster();
|
|
|
|
var split = new MidSideSplit();
|
|
|
|
split.mid.connect(midSideMerge.mid);
|
|
|
|
split.side.connect(midSideMerge.side);
|
|
|
|
var merge = new Merge().connect(split);
|
|
|
|
new Signal(0.2).connect(merge.left);
|
|
|
|
new Signal(0.4).connect(merge.right);
|
|
|
|
}, 0.1, 2).then(function(buffer){
|
|
|
|
buffer.forEach(function(l, r){
|
|
|
|
expect(l).to.be.closeTo(0.2, 0.01);
|
|
|
|
expect(r).to.be.closeTo(0.4, 0.01);
|
2017-02-20 04:55:55 +00:00
|
|
|
});
|
2015-08-28 22:42:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
|