signals inherit Signal.connect method

this is so that params and signals they connect to don’t need to be
manually zeroed out after connecting.

Fixed #11
This commit is contained in:
Yotam Mann 2014-08-24 13:19:49 -04:00
parent e3973aeead
commit b2c85eaf44
19 changed files with 96 additions and 12 deletions

View file

@ -50,10 +50,6 @@ define(["Tone/core/Tone", "Tone/signal/Signal", "Tone/signal/Scale"], function(T
this.chain(this.wetness, this.wet.gain);
//dry control is the inverse of the wet
this.chain(this.wetness, this._invert, this.dry.gain);
this.dry.gain.value = 0;
this.wet.gain.value = 0;
this.setDry(this.defaultArg(initialDry, 0));
};

View file

@ -33,7 +33,6 @@ define(["Tone/core/Tone", "Tone/component/Follower", "Tone/signal/GreaterThan"],
this.chain(this.input, this.output);
//the control signal
this.chain(this.input, this._follower, this._gt, this.output.gain);
this.output.gain.value = 0;
};
Tone.extend(Tone.Gate);

View file

@ -91,7 +91,6 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
this._oscillator.connect(this._jsNode);
//connect it up
this._controlSignal.connect(this._oscillator.frequency);
this._oscillator.frequency.value = 0;
this._upTick = false;
var startTime = this.toSeconds(time);
this._oscillator.start(startTime);

View file

@ -1,4 +1,5 @@
define(["Tone/core/Tone", "Tone/signal/Selector", "Tone/signal/Negate", "Tone/signal/LessThan"], function(Tone){
define(["Tone/core/Tone", "Tone/signal/Selector", "Tone/signal/Negate", "Tone/signal/LessThan", "Tone/signal/Signal"],
function(Tone){
/**
* @class return the absolute value of an incoming signal
@ -39,6 +40,13 @@ define(["Tone/core/Tone", "Tone/signal/Selector", "Tone/signal/Negate", "Tone/si
Tone.extend(Tone.Abs);
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Abs.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -34,6 +34,13 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){
this._value.setValue(value);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Add.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -20,12 +20,14 @@ define(["Tone/core/Tone", "Tone/signal/Max", "Tone/signal/Min"], function(Tone){
/**
* the min clipper
* @type {Tone.Min}
* @private
*/
this._min = new Tone.Min(max);
/**
* the max clipper
* @type {Tone.Max}
* @private
*/
this._max = new Tone.Max(min);
@ -52,6 +54,13 @@ define(["Tone/core/Tone", "Tone/signal/Max", "Tone/signal/Min"], function(Tone){
this._max.setMax(max);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Clip.prototype.connect = Tone.Signal.prototype.connect;
/**
* clean up
*/

View file

@ -44,6 +44,13 @@ define(["Tone/core/Tone", "Tone/signal/EqualZero", "Tone/signal/Add"], function(
this._adder.setValue(-value);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Equal.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -51,6 +51,13 @@ define(["Tone/core/Tone", "Tone/signal/Threshold"], function(Tone){
this._equals.curve = curve;
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.EqualZero.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -74,6 +74,13 @@ define(["Tone/core/Tone", "Tone/signal/Threshold", "Tone/signal/Add"], function(
this._adder.setValue(-value);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.GreaterThan.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -74,6 +74,13 @@ define(["Tone/core/Tone", "Tone/signal/Threshold", "Tone/signal/Add"], function(
this._adder.setValue(-value);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.LessThan.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -47,6 +47,13 @@ define(["Tone/core/Tone", "Tone/signal/GreaterThan", "Tone/signal/Selector"], fu
this._maxSignal.setValue(max);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Max.prototype.connect = Tone.Signal.prototype.connect;
/**
* clean up
*/

View file

@ -47,6 +47,13 @@ define(["Tone/core/Tone", "Tone/signal/LessThan", "Tone/signal/Selector"], funct
this._minSignal.setValue(min);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Min.prototype.connect = Tone.Signal.prototype.connect;
/**
* clean up
*/

View file

@ -31,6 +31,13 @@ define(["Tone/core/Tone"], function(Tone){
this.input.gain.value = value;
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Multiply.prototype.connect = Tone.Signal.prototype.connect;
/**
* clean up
*/

View file

@ -22,6 +22,13 @@ define(["Tone/core/Tone", "Tone/signal/Multiply"], function(Tone){
Tone.extend(Tone.Negate);
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Negate.prototype.connect = Tone.Signal.prototype.connect;
/**
* clean up
*/

View file

@ -90,7 +90,6 @@ define(["Tone/core/Tone", "Tone/signal/Equal", "Tone/signal/Signal"], function(T
//connect the selecter to the gate gain
this.selecter.connect(this.gate.gain);
this.gate.gain.value = 0;
};
Tone.extend(RouteGate);

View file

@ -1,4 +1,4 @@
define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Multiply"], function(Tone){
define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Multiply", "Tone/signal/Signal"], function(Tone){
/**
* @class performs a linear scaling on an input signal.
@ -106,6 +106,13 @@ define(["Tone/core/Tone", "Tone/signal/Add", "Tone/signal/Multiply"], function(T
this._setScalingParameters();
};
/**
* borrows connect from {@link Tone.Signal}
*
* @function
*/
Tone.Scale.prototype.connect = Tone.Signal.prototype.connect;
/**
* clean up
*/

View file

@ -91,7 +91,6 @@ define(["Tone/core/Tone", "Tone/signal/Equal", "Tone/signal/Signal"], function(T
//connect the selecter to the gate gain
this.selecter.connect(this.gate.gain);
this.gate.gain.value = 0;
};
Tone.extend(SelectorGate);

View file

@ -70,6 +70,13 @@ define(["Tone/core/Tone"], function(Tone){
this._setThresh(this._thresh, thresh);
};
/**
* borrows the method from {@link Tone.Signal}
*
* @function
*/
Tone.Threshold.prototype.connect = Tone.Signal.prototype.connect;
/**
* dispose method
*/

View file

@ -59,9 +59,7 @@ function(Tone){
//connect the control signal to the oscillator frequency & detune
this.oscillator.connect(this.output);
this.frequency.connect(this.oscillator.frequency);
this.oscillator.frequency.value = 0;
this.detune.connect(this.oscillator.detune);
this.oscillator.detune.value = 0;
//start the oscillator
this.oscillator.start(this.toSeconds(time));
this.oscillator.onended = this._onended.bind(this);