mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
44 lines
No EOL
1.3 KiB
JavaScript
44 lines
No EOL
1.3 KiB
JavaScript
define(["Tone/core/Tone"], function(Tone){
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* @class Base class for all Signals. Used Internally.
|
|
*
|
|
* @constructor
|
|
* @extends {Tone}
|
|
*/
|
|
Tone.SignalBase = function(){};
|
|
|
|
Tone.extend(Tone.SignalBase);
|
|
|
|
/**
|
|
* 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 default <code>connect</code>.
|
|
*
|
|
* @override
|
|
* @param {AudioParam|AudioNode|Tone.Signal|Tone} node
|
|
* @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
|
|
if (node.constructor === Tone.Signal){
|
|
//cancel changes
|
|
node._value.cancelScheduledValues(0);
|
|
//reset the value
|
|
node._value.value = 0;
|
|
//mark the value as overridden
|
|
node.overridden = true;
|
|
} else if (node instanceof AudioParam){
|
|
node.cancelScheduledValues(0);
|
|
node.value = 0;
|
|
}
|
|
Tone.prototype.connect.call(this, node, outputNumber, inputNumber);
|
|
return this;
|
|
};
|
|
|
|
return Tone.SignalBase;
|
|
}); |