1 | import { connectSeries } from "../core/context/ToneAudioNode.js";
|
2 | import { Gain } from "../core/context/Gain.js";
|
3 | import { optionsFromArguments } from "../core/util/Defaults.js";
|
4 | import { Signal } from "./Signal.js";
|
5 | /**
|
6 | * Add a signal and a number or two signals. When no value is
|
7 | * passed into the constructor, Tone.Add will sum input and `addend`
|
8 | * If a value is passed into the constructor, the it will be added to the input.
|
9 | *
|
10 | * @example
|
11 | * return Tone.Offline(() => {
|
12 | * const add = new Tone.Add(2).toDestination();
|
13 | * add.addend.setValueAtTime(1, 0.2);
|
14 | * const signal = new Tone.Signal(2);
|
15 | * // add a signal and a scalar
|
16 | * signal.connect(add);
|
17 | * signal.setValueAtTime(1, 0.1);
|
18 | * }, 0.5, 1);
|
19 | * @category Signal
|
20 | */
|
21 | export class Add extends Signal {
|
22 | constructor() {
|
23 | super(optionsFromArguments(Add.getDefaults(), arguments, ["value"]));
|
24 | this.override = false;
|
25 | this.name = "Add";
|
26 | /**
|
27 | * the summing node
|
28 | */
|
29 | this._sum = new Gain({ context: this.context });
|
30 | this.input = this._sum;
|
31 | this.output = this._sum;
|
32 | /**
|
33 | * The value which is added to the input signal
|
34 | */
|
35 | this.addend = this._param;
|
36 | connectSeries(this._constantSource, this._sum);
|
37 | }
|
38 | static getDefaults() {
|
39 | return Object.assign(Signal.getDefaults(), {
|
40 | value: 0,
|
41 | });
|
42 | }
|
43 | dispose() {
|
44 | super.dispose();
|
45 | this._sum.dispose();
|
46 | return this;
|
47 | }
|
48 | }
|
49 | //# sourceMappingURL=Add.js.map |
\ | No newline at end of file |