Tone.js/Tone/signal/Multiply.js

69 lines
1.4 KiB
JavaScript
Raw Normal View History

2014-08-24 19:47:59 +00:00
define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
"use strict";
2014-06-17 00:05:54 +00:00
/**
2014-10-23 01:20:43 +00:00
* @class Multiply the incoming signal by a number or Multiply two signals
2014-06-17 00:05:54 +00:00
*
* @constructor
* @extends {Tone}
2014-06-17 15:42:38 +00:00
* @param {number=} value constant value to multiple
2014-06-17 00:05:54 +00:00
*/
Tone.Multiply = function(value){
2014-10-23 01:20:43 +00:00
/**
* input 0: multiplicand
* input 1: multiplier
* @type {Array}
*/
this.input = new Array(2);
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
*/
2014-10-23 01:20:43 +00:00
this._factor = this.input[1] = this.output.gain;
2014-06-30 21:11:46 +00:00
2014-10-23 01:20:43 +00:00
this._factor.value = this.defaultArg(value, 0);
2014-06-15 21:38:59 +00:00
};
Tone.extend(Tone.Multiply);
2014-06-17 00:05:54 +00:00
/**
* set the constant multiple
*
* @param {number} value
*/
Tone.Multiply.prototype.setValue = function(value){
2014-10-23 01:20:43 +00:00
this._factor.value = value;
2014-06-15 21:38:59 +00:00
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Multiply.prototype.connect = Tone.Signal.prototype.connect;
2014-06-20 04:38:14 +00:00
/**
* clean up
*/
Tone.Multiply.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
2014-10-23 01:20:43 +00:00
this._mult = null;
this._factor = null;
2014-06-20 04:38:14 +00:00
};
return Tone.Multiply;
2014-06-15 21:38:59 +00:00
});