UNPKG

1.42 kBJavaScriptView Raw
1import { Scale } from "./Scale.js";
2import { optionsFromArguments } from "../core/util/Defaults.js";
3import { Pow } from "./Pow.js";
4/**
5 * Performs an exponential scaling on an input signal.
6 * Scales a NormalRange value [0,1] exponentially
7 * to the output range of outputMin to outputMax.
8 * @example
9 * const scaleExp = new Tone.ScaleExp(0, 100, 2);
10 * const signal = new Tone.Signal(0.5).connect(scaleExp);
11 * @category Signal
12 */
13export class ScaleExp extends Scale {
14 constructor() {
15 const options = optionsFromArguments(ScaleExp.getDefaults(), arguments, ["min", "max", "exponent"]);
16 super(options);
17 this.name = "ScaleExp";
18 this.input = this._exp = new Pow({
19 context: this.context,
20 value: options.exponent,
21 });
22 this._exp.connect(this._mult);
23 }
24 static getDefaults() {
25 return Object.assign(Scale.getDefaults(), {
26 exponent: 1,
27 });
28 }
29 /**
30 * Instead of interpolating linearly between the {@link min} and
31 * {@link max} values, setting the exponent will interpolate between
32 * the two values with an exponential curve.
33 */
34 get exponent() {
35 return this._exp.value;
36 }
37 set exponent(exp) {
38 this._exp.value = exp;
39 }
40 dispose() {
41 super.dispose();
42 this._exp.dispose();
43 return this;
44 }
45}
46//# sourceMappingURL=ScaleExp.js.map
\No newline at end of file