2015-10-21 16:11:41 +00:00
|
|
|
define(["Tone/core/Tone"], function(Tone){
|
2014-12-01 04:26:06 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
2015-06-19 04:52:04 +00:00
|
|
|
* @class Base class for all Signals. Used Internally.
|
2014-12-01 04:26:06 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2014-12-02 05:27:28 +00:00
|
|
|
* @extends {Tone}
|
2014-12-01 04:26:06 +00:00
|
|
|
*/
|
2015-06-20 19:50:57 +00:00
|
|
|
Tone.SignalBase = function(){};
|
2014-12-01 04:26:06 +00:00
|
|
|
|
|
|
|
Tone.extend(Tone.SignalBase);
|
|
|
|
|
|
|
|
/**
|
2015-02-27 18:40:35 +00:00
|
|
|
* When signals connect to other signals or AudioParams,
|
|
|
|
* they take over the output value of that signal or AudioParam.
|
2015-06-19 04:52:04 +00:00
|
|
|
* For all other nodes, the behavior is the same as a default <code>connect</code>.
|
2014-12-01 04:26:06 +00:00
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @param {AudioParam|AudioNode|Tone.Signal|Tone} node
|
2015-06-19 04:52:04 +00:00
|
|
|
* @param {number} [outputNumber=0] The output number to connect from.
|
|
|
|
* @param {number} [inputNumber=0] The input number to connect to.
|
2015-06-14 00:54:29 +00:00
|
|
|
* @returns {Tone.SignalBase} this
|
2014-12-01 04:26:06 +00:00
|
|
|
*/
|
|
|
|
Tone.SignalBase.prototype.connect = function(node, outputNumber, inputNumber){
|
|
|
|
//zero it out so that the signal can have full control
|
2015-10-21 16:11:41 +00:00
|
|
|
if ((Tone.Signal && Tone.Signal === node.constructor) ||
|
|
|
|
(Tone.Param && Tone.Param === node.constructor) ||
|
|
|
|
(Tone.TimelineSignal && Tone.TimelineSignal === node.constructor)){
|
2015-02-21 19:05:58 +00:00
|
|
|
//cancel changes
|
2015-10-21 14:27:44 +00:00
|
|
|
node._param.cancelScheduledValues(0);
|
2015-02-21 19:05:58 +00:00
|
|
|
//reset the value
|
2015-10-21 14:27:44 +00:00
|
|
|
node._param.value = 0;
|
2015-05-23 22:57:05 +00:00
|
|
|
//mark the value as overridden
|
|
|
|
node.overridden = true;
|
2015-02-20 05:53:39 +00:00
|
|
|
} else if (node instanceof AudioParam){
|
2015-02-23 05:30:53 +00:00
|
|
|
node.cancelScheduledValues(0);
|
2014-12-01 04:26:06 +00:00
|
|
|
node.value = 0;
|
|
|
|
}
|
|
|
|
Tone.prototype.connect.call(this, node, outputNumber, inputNumber);
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
2014-12-01 04:26:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.SignalBase;
|
|
|
|
});
|