2015-02-23 05:30:53 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/GreaterThanZero", "Tone/signal/Subtract", "Tone/signal/Signal"],
|
|
|
|
function(Tone){
|
2014-07-04 02:59:16 +00:00
|
|
|
|
2014-09-04 04:41:40 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-07-04 02:59:16 +00:00
|
|
|
/**
|
2014-10-23 01:25:28 +00:00
|
|
|
* @class Output 1 if the signal is greater than the value, otherwise outputs 0.
|
2014-10-23 01:24:40 +00:00
|
|
|
* can compare two signals or a signal and a number.
|
2014-07-04 02:59:16 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2015-02-23 05:30:53 +00:00
|
|
|
* @extends {Tone.Signal}
|
2014-12-02 06:42:08 +00:00
|
|
|
* @param {number} [value=0] the value to compare to the incoming signal
|
2014-07-04 02:59:16 +00:00
|
|
|
*/
|
|
|
|
Tone.GreaterThan = function(value){
|
2014-10-23 01:24:40 +00:00
|
|
|
|
2014-11-04 06:21:42 +00:00
|
|
|
Tone.call(this, 2, 0);
|
2014-10-03 17:07:26 +00:00
|
|
|
|
2014-07-04 02:59:16 +00:00
|
|
|
/**
|
2014-10-03 17:07:26 +00:00
|
|
|
* subtract the amount from the incoming signal
|
2014-10-23 01:24:40 +00:00
|
|
|
* @type {Tone.Subtract}
|
2014-07-04 02:59:16 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2015-02-23 05:30:53 +00:00
|
|
|
this._value = this.input[0] = new Tone.Subtract(value);
|
|
|
|
this.input[1] = this._value.input[1];
|
2014-07-04 02:59:16 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-03 17:07:26 +00:00
|
|
|
* compare that amount to zero
|
|
|
|
* @type {Tone.GreaterThanZero}
|
2014-07-04 02:59:16 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2014-10-23 01:24:40 +00:00
|
|
|
this._gtz = this.output = new Tone.GreaterThanZero();
|
2014-07-04 02:59:16 +00:00
|
|
|
|
|
|
|
//connect
|
2015-02-23 05:30:53 +00:00
|
|
|
this._value.connect(this._gtz);
|
2014-07-04 02:59:16 +00:00
|
|
|
};
|
|
|
|
|
2015-02-23 05:30:53 +00:00
|
|
|
Tone.extend(Tone.GreaterThan, Tone.Signal);
|
2015-02-02 17:50:18 +00:00
|
|
|
|
2014-07-04 02:59:16 +00:00
|
|
|
/**
|
|
|
|
* dispose method
|
2015-02-02 03:56:33 +00:00
|
|
|
* @returns {Tone.GreaterThan} `this`
|
2014-07-04 02:59:16 +00:00
|
|
|
*/
|
|
|
|
Tone.GreaterThan.prototype.dispose = function(){
|
2014-09-06 22:55:11 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2015-02-23 05:30:53 +00:00
|
|
|
this._value.dispose();
|
|
|
|
this._value = null;
|
2014-10-03 17:07:26 +00:00
|
|
|
this._gtz.dispose();
|
|
|
|
this._gtz = null;
|
2015-02-02 03:56:33 +00:00
|
|
|
return this;
|
2014-07-04 02:59:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Tone.GreaterThan;
|
|
|
|
});
|