2019-01-27 18:05:20 +00:00
|
|
|
import Test from "helper/Test";
|
|
|
|
import Gain from "Tone/core/Gain";
|
|
|
|
import Tone from "Tone/core/Tone";
|
|
|
|
import PassAudio from "helper/PassAudio";
|
|
|
|
import Basic from "helper/Basic";
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
describe("Gain", function(){
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Basic(Gain);
|
2018-07-29 13:39:22 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var gain = new Gain();
|
|
|
|
gain.dispose();
|
|
|
|
Test.wasDisposed(gain);
|
|
|
|
});
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("handles input and output connections", function(){
|
|
|
|
var gain = new Gain();
|
|
|
|
gain.connect(Test);
|
|
|
|
Test.connect(gain);
|
|
|
|
Test.connect(gain.gain);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can set the gain value", function(){
|
|
|
|
var gain = new Gain();
|
|
|
|
gain.gain.value = 0.2;
|
|
|
|
expect(gain.gain.value).to.be.closeTo(0.2, 0.001);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be constructed with options object", function(){
|
2015-10-21 14:55:56 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
var gain = new Gain({
|
|
|
|
"gain" : 0.4
|
|
|
|
});
|
|
|
|
expect(gain.gain.value).to.be.closeTo(0.4, 0.001);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be constructed with an initial value", function(){
|
|
|
|
var gain = new Gain(3);
|
|
|
|
expect(gain.gain.value).to.be.closeTo(3, 0.001);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2015-10-21 14:55:56 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can set the units", function(){
|
|
|
|
var gain = new Gain(0, Tone.Type.Decibels);
|
|
|
|
expect(gain.gain.value).to.be.closeTo(0, 0.001);
|
|
|
|
expect(gain.gain.units).to.equal(Tone.Type.Decibels);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2015-10-21 14:55:56 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can get the value using 'get'", function(){
|
|
|
|
var gain = new Gain(5);
|
|
|
|
var value = gain.get();
|
|
|
|
expect(value.gain).to.be.closeTo(5, 0.001);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2015-08-16 18:23:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can set the value using 'set'", function(){
|
|
|
|
var gain = new Gain(5);
|
|
|
|
gain.set("gain", 4);
|
|
|
|
expect(gain.gain.value).to.be.closeTo(4, 0.001);
|
|
|
|
gain.dispose();
|
|
|
|
});
|
2017-12-30 16:26:29 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("passes audio through", function(){
|
|
|
|
return PassAudio(function(input){
|
|
|
|
var gain = new Gain().toMaster();
|
|
|
|
input.connect(gain);
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|