diff --git a/Tone/signal/Add.js b/Tone/signal/Add.js index a9abe6e4..83235829 100644 --- a/Tone/signal/Add.js +++ b/Tone/signal/Add.js @@ -27,7 +27,7 @@ define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/core/Gain"], function(Tone */ Tone.Add = function(value){ - Tone.Param.call(this); + Tone.Signal.call(this); 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.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 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 */ Tone.Add.prototype.dispose = function(){ - Tone.Param.prototype.dispose.call(this); + Tone.Signal.prototype.dispose.call(this); this._sum.dispose(); this._sum = null; return this; diff --git a/Tone/signal/GreaterThan.js b/Tone/signal/GreaterThan.js index ffeb5f10..97b7ffa0 100644 --- a/Tone/signal/GreaterThan.js +++ b/Tone/signal/GreaterThan.js @@ -16,7 +16,7 @@ define(["Tone/core/Tone", "Tone/signal/GreaterThanZero", "Tone/signal/Subtract", */ Tone.GreaterThan = function(value){ - Tone.Param.call(this); + Tone.Signal.call(this); this.createInsOuts(2, 0); /** @@ -36,9 +36,10 @@ define(["Tone/core/Tone", "Tone/signal/GreaterThanZero", "Tone/signal/Subtract", //connect 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 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 */ Tone.GreaterThan.prototype.dispose = function(){ - Tone.Param.prototype.dispose.call(this); + Tone.Signal.prototype.dispose.call(this); this._gtz.dispose(); this._gtz = null; return this; diff --git a/Tone/signal/Multiply.js b/Tone/signal/Multiply.js index 603c6dec..1a96f8e1 100644 --- a/Tone/signal/Multiply.js +++ b/Tone/signal/Multiply.js @@ -7,7 +7,7 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign * multiplies the incoming signal by that value. * * @constructor - * @extends {Tone.Param} + * @extends {Tone.Signal} * @param {number=} value Constant value to multiple. If no value is provided, * it will return the product of the first and second inputs * @example @@ -24,7 +24,7 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign */ Tone.Multiply = function(value){ - Tone.Param.call(this); + Tone.Signal.call(this); this.createInsOuts(2, 0); /** @@ -42,11 +42,11 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign * @private */ this._param = this.input[1] = this.output.gain; - 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; @@ -55,7 +55,7 @@ define(["Tone/core/Tone", "Tone/core/Param", "Tone/core/Gain", "Tone/signal/Sign * @returns {Tone.Multiply} this */ Tone.Multiply.prototype.dispose = function(){ - Tone.Param.prototype.dispose.call(this); + Tone.Signal.prototype.dispose.call(this); this._mult.dispose(); this._mult = null; this._param = null; diff --git a/Tone/signal/Signal.js b/Tone/signal/Signal.js index 5e3b00de..a1cc9d76 100644 --- a/Tone/signal/Signal.js +++ b/Tone/signal/Signal.js @@ -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 * that also applies the automation to all the proxied connections. diff --git a/Tone/signal/Subtract.js b/Tone/signal/Subtract.js index c585722d..ca3a19c8 100644 --- a/Tone/signal/Subtract.js +++ b/Tone/signal/Subtract.js @@ -25,7 +25,7 @@ define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Negate", "Tone/signal/ */ Tone.Subtract = function(value){ - Tone.Param.call(this); + Tone.Signal.call(this); this.createInsOuts(2, 0); /** @@ -49,11 +49,11 @@ define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Negate", "Tone/signal/ * @type {Tone.Signal} */ this._param = this.input[1] = new Tone.Signal(value); - 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 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 */ Tone.Subtract.prototype.dispose = function(){ - Tone.Param.prototype.dispose.call(this); + Tone.Signal.prototype.dispose.call(this); this._neg.dispose(); this._neg = null; this._sum.disconnect(); diff --git a/Tone/signal/TickSignal.js b/Tone/signal/TickSignal.js index 3a687362..e2bc31ae 100644 --- a/Tone/signal/TickSignal.js +++ b/Tone/signal/TickSignal.js @@ -11,15 +11,25 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){ * @param {Number} value The initial value of the signal * @extends {Tone.Signal} */ - Tone.TickSignal = function(value){ + Tone.TickSignal = function(value, param){ value = Tone.defaultArg(value, 1); Tone.Signal.call(this, { "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 this._events.memory = Infinity; @@ -31,12 +41,13 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){ "time" : 0, "value" : value }); + this.proxy = false; }; 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. * @param {Function} method * @return {Function}