2014-12-01 04:26:06 +00:00
|
|
|
define(["Tone/core/Tone"], function(Tone){
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Base class for all Signals
|
|
|
|
*
|
|
|
|
* @constructor
|
2014-12-02 05:27:28 +00:00
|
|
|
* @extends {Tone}
|
2014-12-01 04:26:06 +00:00
|
|
|
*/
|
|
|
|
Tone.SignalBase = function(){
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
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.
|
|
|
|
* For all other nodes, the behavior is the same as a normal `connect`.
|
2014-12-01 04:26:06 +00:00
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @param {AudioParam|AudioNode|Tone.Signal|Tone} node
|
2014-12-02 06:42:08 +00:00
|
|
|
* @param {number} [outputNumber=0]
|
|
|
|
* @param {number} [inputNumber=0]
|
2015-02-02 03:56:33 +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-02-23 05:30:53 +00:00
|
|
|
if (node.constructor === Tone.Signal){
|
2015-02-21 19:05:58 +00:00
|
|
|
//cancel changes
|
|
|
|
node._value.cancelScheduledValues(0);
|
|
|
|
//reset the value
|
2015-02-20 05:53:39 +00:00
|
|
|
node._value.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;
|
|
|
|
});
|