Tone.js/test/signal/ScaleExp.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-02-20 21:40:41 +00:00
define(["helper/ConstantOutput", "Tone/signal/ScaleExp", "helper/Basic",
2015-08-24 15:17:21 +00:00
"Test", "Tone/source/Oscillator", "Tone/signal/Signal"],
2017-02-20 21:40:41 +00:00
function (ConstantOutput, ScaleExp, Basic, Test, Oscillator, Signal) {
2015-08-24 15:17:21 +00:00
describe("ScaleExp", function(){
Basic(ScaleExp);
context("Scaling", function(){
it("handles input and output connections", function(){
var scale = new ScaleExp(0, 100, 2);
Test.connect(scale);
scale.connect(Test);
scale.dispose();
});
it("can set the min and max values", function(){
var scale = new ScaleExp(-20, 10, 2);
scale.min = -0.01;
expect(scale.min).to.be.closeTo(-0.01, 0.001);
scale.max = 1000;
expect(scale.max).to.be.closeTo(1000, 0.001);
scale.dispose();
});
it("can set the exponent value", function(){
var scale = new ScaleExp(0, 100, 2);
expect(scale.exponent).to.be.closeTo(2, 0.001);
scale.exponent = 3;
expect(scale.exponent).to.be.closeTo(3, 0.001);
scale.dispose();
});
2017-02-20 21:40:41 +00:00
it("scales a signal exponentially", function(){
return ConstantOutput(function(){
var signal = new Signal(0.5);
var scale = new ScaleExp(0, 1, 2);
2015-08-24 15:17:21 +00:00
signal.connect(scale);
2017-02-20 21:40:41 +00:00
scale.toMaster();
}, 0.25);
2015-08-24 15:17:21 +00:00
});
});
});
});