Tone.js/Tone/signal/SignalBase.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-10-21 16:11:41 +00:00
define(["Tone/core/Tone"], function(Tone){
"use strict";
/**
2015-06-19 04:52:04 +00:00
* @class Base class for all Signals. Used Internally.
*
* @constructor
2014-12-02 05:27:28 +00:00
* @extends {Tone}
*/
2015-06-20 19:50:57 +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.
2015-06-19 04:52:04 +00:00
* For all other nodes, the behavior is the same as a default <code>connect</code>.
*
* @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.
* @returns {Tone.SignalBase} this
*/
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;
//mark the value as overridden
node.overridden = true;
} else if (node instanceof AudioParam){
2015-02-23 05:30:53 +00:00
node.cancelScheduledValues(0);
node.value = 0;
}
Tone.prototype.connect.call(this, node, outputNumber, inputNumber);
2015-02-02 03:56:33 +00:00
return this;
};
return Tone.SignalBase;
});