2014-08-24 19:47:59 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/Signal"], 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
|
|
|
/**
|
2014-11-04 06:21:42 +00:00
|
|
|
* @class Multiply the incoming signal by a number or Multiply two signals.
|
|
|
|
* input 0: multiplicand.
|
|
|
|
* input 1: multiplier.
|
2014-06-17 00:05:54 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2015-02-23 05:30:53 +00:00
|
|
|
* @extends {Tone.Signal}
|
2014-12-03 22:20:23 +00:00
|
|
|
* @param {number=} value constant value to multiple. if no value is provided
|
|
|
|
* it will be multiplied by the value of input 1.
|
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
|
|
|
|
2014-11-04 06:21:42 +00:00
|
|
|
Tone.call(this, 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
|
|
|
|
*
|
|
|
|
* @type {GainNode}
|
2014-10-23 01:20:43 +00:00
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._mult = this.input[0] = this.output = this.context.createGain();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the scaling parameter
|
|
|
|
* @type {AudioParam}
|
|
|
|
* @private
|
2014-06-17 15:42:38 +00:00
|
|
|
*/
|
2015-02-23 05:30:53 +00:00
|
|
|
this._value = this.input[1] = this.output.gain;
|
2014-06-30 21:11:46 +00:00
|
|
|
|
2015-02-23 05:30:53 +00:00
|
|
|
this._value.value = this.defaultArg(value, 0);
|
2014-06-15 21:38:59 +00:00
|
|
|
};
|
2014-04-16 20:47:25 +00:00
|
|
|
|
2015-02-23 05:30:53 +00:00
|
|
|
Tone.extend(Tone.Multiply, Tone.Signal);
|
2014-04-16 20:47:25 +00:00
|
|
|
|
2014-06-20 04:38:14 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
2015-02-02 03:56:33 +00:00
|
|
|
* @returns {Tone.Multiply} `this`
|
2014-06-20 04:38:14 +00:00
|
|
|
*/
|
|
|
|
Tone.Multiply.prototype.dispose = function(){
|
2014-09-06 22:55:11 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2014-10-23 01:20:43 +00:00
|
|
|
this._mult = null;
|
2015-02-23 05:30:53 +00:00
|
|
|
this._value = null;
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
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
|
|
|
});
|