2018-06-06 01:53:28 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/SignalBase"], function(Tone){
|
2014-04-16 20:47:25 +00:00
|
|
|
|
2014-09-04 04:41:40 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-06-17 00:05:54 +00:00
|
|
|
/**
|
2017-12-30 02:15:10 +00:00
|
|
|
* @class Multiply two incoming signals. Or, if a number is given in the constructor,
|
|
|
|
* multiplies the incoming signal by that value.
|
2014-06-17 00:05:54 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2018-06-06 02:42:17 +00:00
|
|
|
* @extends {Tone.Signal}
|
2015-06-19 04:52:04 +00:00
|
|
|
* @param {number=} value Constant value to multiple. If no value is provided,
|
|
|
|
* it will return the product of the first and second inputs
|
2015-02-27 18:40:35 +00:00
|
|
|
* @example
|
2015-06-19 04:52:04 +00:00
|
|
|
* var mult = new Tone.Multiply();
|
|
|
|
* var sigA = new Tone.Signal(3);
|
|
|
|
* var sigB = new Tone.Signal(4);
|
|
|
|
* sigA.connect(mult, 0, 0);
|
|
|
|
* sigB.connect(mult, 0, 1);
|
|
|
|
* //output of mult is 12.
|
2015-06-20 19:50:57 +00:00
|
|
|
* @example
|
|
|
|
* var mult = new Tone.Multiply(10);
|
|
|
|
* var sig = new Tone.Signal(2).connect(mult);
|
2017-12-30 02:15:10 +00:00
|
|
|
* //the output of mult is 20.
|
2014-06-17 00:05:54 +00:00
|
|
|
*/
|
2014-04-16 23:56:18 +00:00
|
|
|
Tone.Multiply = function(value){
|
2014-10-23 01:20:43 +00:00
|
|
|
|
2018-06-06 02:42:17 +00:00
|
|
|
Tone.Signal.call(this);
|
2016-09-20 03:02:42 +00:00
|
|
|
this.createInsOuts(2, 0);
|
2014-10-23 01:20:43 +00:00
|
|
|
|
2014-06-17 15:42:38 +00:00
|
|
|
/**
|
|
|
|
* the input node is the same as the output node
|
|
|
|
* it is also the GainNode which handles the scaling of incoming signal
|
2017-12-30 02:15:10 +00:00
|
|
|
*
|
2014-06-17 15:42:38 +00:00
|
|
|
* @type {GainNode}
|
2014-10-23 01:20:43 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2016-09-20 01:44:41 +00:00
|
|
|
this._mult = this.input[0] = this.output = new Tone.Gain();
|
2014-10-23 01:20:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the scaling parameter
|
|
|
|
* @type {AudioParam}
|
|
|
|
* @private
|
2014-06-17 15:42:38 +00:00
|
|
|
*/
|
2015-10-21 14:34:37 +00:00
|
|
|
this._param = this.input[1] = this.output.gain;
|
2017-12-30 02:15:10 +00:00
|
|
|
this.value = Tone.defaultArg(value, 0);
|
2018-06-06 02:42:17 +00:00
|
|
|
this.proxy = false;
|
2014-06-15 21:38:59 +00:00
|
|
|
};
|
2014-04-16 20:47:25 +00:00
|
|
|
|
2018-06-06 02:42:17 +00:00
|
|
|
Tone.extend(Tone.Multiply, Tone.Signal);
|
2018-06-06 01:53:28 +00:00
|
|
|
|
2014-06-20 04:38:14 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.Multiply} this
|
2014-06-20 04:38:14 +00:00
|
|
|
*/
|
|
|
|
Tone.Multiply.prototype.dispose = function(){
|
2018-06-06 02:42:17 +00:00
|
|
|
Tone.Signal.prototype.dispose.call(this);
|
2016-09-20 03:02:42 +00:00
|
|
|
this._mult.dispose();
|
2014-10-23 01:20:43 +00:00
|
|
|
this._mult = null;
|
2015-10-21 14:34:37 +00:00
|
|
|
this._param = null;
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
2017-12-30 02:15:10 +00:00
|
|
|
};
|
2014-06-20 04:38:14 +00:00
|
|
|
|
2014-04-16 20:47:25 +00:00
|
|
|
return Tone.Multiply;
|
2014-06-15 21:38:59 +00:00
|
|
|
});
|