signals extend Tone.Signal again

but are set proxy = false initially
This commit is contained in:
tambien 2018-06-05 22:42:17 -04:00
parent eb003d8b6c
commit 442c7cb1c5
6 changed files with 44 additions and 18 deletions

View file

@ -27,7 +27,7 @@ define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Gain"], function(Tone
*/ */
Tone.Add = function(value){ Tone.Add = function(value){
Tone.Param.call(this); Tone.Signal.call(this);
this.createInsOuts(2, 0); this.createInsOuts(2, 0);
/** /**
@ -44,9 +44,10 @@ define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Gain"], function(Tone
this._param = this.input[1] = new Tone.Signal(value); this._param = this.input[1] = new Tone.Signal(value);
this._param.connect(this._sum); this._param.connect(this._sum);
this.proxy = false;
}; };
Tone.extend(Tone.Add, Tone.Param); Tone.extend(Tone.Add, Tone.Signal);
//return the connect method back to signal //return the connect method back to signal
Tone.Add.prototype.connect = Tone.SignalBase.prototype.connect; Tone.Add.prototype.connect = Tone.SignalBase.prototype.connect;
@ -56,7 +57,7 @@ define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Gain"], function(Tone
* @returns {Tone.Add} this * @returns {Tone.Add} this
*/ */
Tone.Add.prototype.dispose = function(){ Tone.Add.prototype.dispose = function(){
Tone.Param.prototype.dispose.call(this); Tone.Signal.prototype.dispose.call(this);
this._sum.dispose(); this._sum.dispose();
this._sum = null; this._sum = null;
return this; return this;

View file

@ -16,7 +16,7 @@ define(["Tone/core/Tone", "Tone/signal/GreaterThanZero", "Tone/signal/Subtract",
*/ */
Tone.GreaterThan = function(value){ Tone.GreaterThan = function(value){
Tone.Param.call(this); Tone.Signal.call(this);
this.createInsOuts(2, 0); this.createInsOuts(2, 0);
/** /**
@ -36,9 +36,10 @@ define(["Tone/core/Tone", "Tone/signal/GreaterThanZero", "Tone/signal/Subtract",
//connect //connect
this._param.connect(this._gtz); this._param.connect(this._gtz);
this.proxy = false;
}; };
Tone.extend(Tone.GreaterThan, Tone.Param); Tone.extend(Tone.GreaterThan, Tone.Signal);
//return the connect method back to signal //return the connect method back to signal
Tone.GreaterThan.prototype.connect = Tone.SignalBase.prototype.connect; Tone.GreaterThan.prototype.connect = Tone.SignalBase.prototype.connect;
@ -48,7 +49,7 @@ define(["Tone/core/Tone", "Tone/signal/GreaterThanZero", "Tone/signal/Subtract",
* @returns {Tone.GreaterThan} this * @returns {Tone.GreaterThan} this
*/ */
Tone.GreaterThan.prototype.dispose = function(){ Tone.GreaterThan.prototype.dispose = function(){
Tone.Param.prototype.dispose.call(this); Tone.Signal.prototype.dispose.call(this);
this._gtz.dispose(); this._gtz.dispose();
this._gtz = null; this._gtz = null;
return this; return this;

View file

@ -7,7 +7,7 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign
* multiplies the incoming signal by that value. * multiplies the incoming signal by that value.
* *
* @constructor * @constructor
* @extends {Tone.Param} * @extends {Tone.Signal}
* @param {number=} value Constant value to multiple. If no value is provided, * @param {number=} value Constant value to multiple. If no value is provided,
* it will return the product of the first and second inputs * it will return the product of the first and second inputs
* @example * @example
@ -24,7 +24,7 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign
*/ */
Tone.Multiply = function(value){ Tone.Multiply = function(value){
Tone.Param.call(this); Tone.Signal.call(this);
this.createInsOuts(2, 0); this.createInsOuts(2, 0);
/** /**
@ -42,11 +42,11 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign
* @private * @private
*/ */
this._param = this.input[1] = this.output.gain; this._param = this.input[1] = this.output.gain;
this.value = Tone.defaultArg(value, 0); this.value = Tone.defaultArg(value, 0);
this.proxy = false;
}; };
Tone.extend(Tone.Multiply, Tone.Param); Tone.extend(Tone.Multiply, Tone.Signal);
Tone.Multiply.prototype.connect = Tone.SignalBase.prototype.connect; Tone.Multiply.prototype.connect = Tone.SignalBase.prototype.connect;
@ -55,7 +55,7 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign
* @returns {Tone.Multiply} this * @returns {Tone.Multiply} this
*/ */
Tone.Multiply.prototype.dispose = function(){ Tone.Multiply.prototype.dispose = function(){
Tone.Param.prototype.dispose.call(this); Tone.Signal.prototype.dispose.call(this);
this._mult.dispose(); this._mult.dispose();
this._mult = null; this._mult = null;
this._param = null; this._param = null;

View file

@ -201,6 +201,19 @@ define(["Tone/core/Tone", "Tone/signal/WaveShaper", "Tone/type/Type", "Tone/core
} }
}); });
/**
* Return the current signal value at the given time.
* @param {Time} time When to get the signal value
* @return {Number}
*/
Tone.Signal.prototype.getValueAtTime = function(time){
if (this._param.getValueAtTime){
return this._param.getValueAtTime(time);
} else {
return Tone.Param.prototype.getValueAtTime.call(this, time);
}
};
/** /**
* Wrap the native scheduling methods with a method * Wrap the native scheduling methods with a method
* that also applies the automation to all the proxied connections. * that also applies the automation to all the proxied connections.

View file

@ -25,7 +25,7 @@ define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Negate", "Tone/signal/
*/ */
Tone.Subtract = function(value){ Tone.Subtract = function(value){
Tone.Param.call(this); Tone.Signal.call(this);
this.createInsOuts(2, 0); this.createInsOuts(2, 0);
/** /**
@ -49,11 +49,11 @@ define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Negate", "Tone/signal/
* @type {Tone.Signal} * @type {Tone.Signal}
*/ */
this._param = this.input[1] = new Tone.Signal(value); this._param = this.input[1] = new Tone.Signal(value);
this._param.chain(this._neg, this._sum); this._param.chain(this._neg, this._sum);
this.proxy = false;
}; };
Tone.extend(Tone.Subtract, Tone.Param); Tone.extend(Tone.Subtract, Tone.Signal);
//return the connect method back to signal //return the connect method back to signal
Tone.Subtract.prototype.connect = Tone.SignalBase.prototype.connect; Tone.Subtract.prototype.connect = Tone.SignalBase.prototype.connect;
@ -63,7 +63,7 @@ define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Negate", "Tone/signal/
* @returns {Tone.SignalBase} this * @returns {Tone.SignalBase} this
*/ */
Tone.Subtract.prototype.dispose = function(){ Tone.Subtract.prototype.dispose = function(){
Tone.Param.prototype.dispose.call(this); Tone.Signal.prototype.dispose.call(this);
this._neg.dispose(); this._neg.dispose();
this._neg = null; this._neg = null;
this._sum.disconnect(); this._sum.disconnect();

View file

@ -11,15 +11,25 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
* @param {Number} value The initial value of the signal * @param {Number} value The initial value of the signal
* @extends {Tone.Signal} * @extends {Tone.Signal}
*/ */
Tone.TickSignal = function(value){ Tone.TickSignal = function(value, param){
value = Tone.defaultArg(value, 1); value = Tone.defaultArg(value, 1);
Tone.Signal.call(this, { Tone.Signal.call(this, {
"units" : Tone.Type.Ticks, "units" : Tone.Type.Ticks,
"value" : value "value" : value,
}); });
if (!param){
var signal = this.context.createConstantSource();
this._param = signal.offset;
this.value = value;
this.output = signal;
signal.start(0);
} else {
this._param = param;
}
//extend the memory //extend the memory
this._events.memory = Infinity; this._events.memory = Infinity;
@ -31,12 +41,13 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
"time" : 0, "time" : 0,
"value" : value "value" : value
}); });
this.proxy = false;
}; };
Tone.extend(Tone.TickSignal, Tone.Signal); Tone.extend(Tone.TickSignal, Tone.Signal);
/** /**
* Wraps Tone.Signal methods so that they also * Wraps Tone.Param methods so that they also
* record the ticks. * record the ticks.
* @param {Function} method * @param {Function} method
* @return {Function} * @return {Function}