Tone.Mono coerces the incoming mono or stereo signal into a mono signal

This commit is contained in:
Yotam Mann 2018-02-05 16:40:55 -05:00
parent c91c1354e0
commit 56c12fb627
2 changed files with 48 additions and 2 deletions

View file

@ -24,10 +24,9 @@ define(["Tone/core/Tone", "Tone/component/Merge", "Tone/core/AudioNode"], functi
this.input.connect(this._merge, 0, 0);
this.input.connect(this._merge, 0, 1);
this.input.gain.value = Tone.dbToGain(-10);
};
Tone.extend(Tone.Mono);
Tone.extend(Tone.Mono, Tone.AudioNode);
/**
* clean up

47
test/component/Mono.js Normal file
View file

@ -0,0 +1,47 @@
define(["Tone/component/Mono", "helper/Basic",
"Test", "helper/Offline", "Tone/signal/Signal", "helper/StereoSignal"],
function(Mono, Basic, Test, Offline, Signal, StereoSignal) {
describe("Mono", function(){
Basic(Mono);
context("Mono", function(){
it("handles input and output connections", function(){
var mono = new Mono();
Test.connect(mono);
mono.connect(Test);
mono.dispose();
});
it("Makes a mono signal in both channels", function(){
return Offline(function(){
var mono = new Mono().toMaster();
var signal = new Signal(2).connect(mono);
}, 0.1, 2).then(function(buffer){
expect(buffer.toArray()[0][0]).to.equal(2);
expect(buffer.toArray()[1][0]).to.equal(2);
expect(buffer.toArray()[0][100]).to.equal(2);
expect(buffer.toArray()[1][100]).to.equal(2);
expect(buffer.toArray()[0][1000]).to.equal(2);
expect(buffer.toArray()[1][1000]).to.equal(2);
});
});
it("Sums a stereo signal into a mono signal", function(){
return Offline(function(){
var mono = new Mono().toMaster();
var signal = StereoSignal(2, 1).connect(mono);
}, 0.1, 2).then(function(buffer){
expect(buffer.toArray()[0][0]).to.equal(1.5);
expect(buffer.toArray()[1][0]).to.equal(1.5);
expect(buffer.toArray()[0][100]).to.equal(1.5);
expect(buffer.toArray()[1][100]).to.equal(1.5);
expect(buffer.toArray()[0][1000]).to.equal(1.5);
expect(buffer.toArray()[1][1000]).to.equal(1.5);
});
});
});
});
});