2019-01-27 18:05:20 +00:00
|
|
|
import Tone from "../core/Tone";
|
|
|
|
import "../signal/GreaterThanZero";
|
|
|
|
import "../signal/Subtract";
|
|
|
|
import "../signal/Signal";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Output 1 if the signal is greater than the value, otherwise outputs 0.
|
|
|
|
* can compare two signals or a signal and a number.
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.Signal}
|
|
|
|
* @param {number} [value=0] the value to compare to the incoming signal
|
|
|
|
* @example
|
|
|
|
* var gt = new Tone.GreaterThan(2);
|
|
|
|
* var sig = new Tone.Signal(4).connect(gt);
|
|
|
|
* //output of gt is equal 1.
|
|
|
|
*/
|
|
|
|
Tone.GreaterThan = function(value){
|
|
|
|
|
|
|
|
Tone.Signal.call(this);
|
|
|
|
this.createInsOuts(2, 0);
|
2014-09-04 04:41:40 +00:00
|
|
|
|
2014-07-04 02:59:16 +00:00
|
|
|
/**
|
2019-01-27 18:05:20 +00:00
|
|
|
* subtract the amount from the incoming signal
|
|
|
|
* @type {Tone.Subtract}
|
|
|
|
* @private
|
2014-07-04 02:59:16 +00:00
|
|
|
*/
|
2019-01-27 18:05:20 +00:00
|
|
|
this._param = this.input[0] = new Tone.Subtract(value);
|
|
|
|
this.input[1] = this._param.input[1];
|
2014-10-23 01:24:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* compare that amount to zero
|
|
|
|
* @type {Tone.GreaterThanZero}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._gtz = this.output = new Tone.GreaterThanZero();
|
2017-10-21 23:02:46 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
//connect
|
|
|
|
this._param.connect(this._gtz);
|
|
|
|
};
|
2014-07-04 02:59:16 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.extend(Tone.GreaterThan, Tone.Signal);
|
2014-07-04 02:59:16 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* dispose method
|
|
|
|
* @returns {Tone.GreaterThan} this
|
|
|
|
*/
|
|
|
|
Tone.GreaterThan.prototype.dispose = function(){
|
|
|
|
Tone.Signal.prototype.dispose.call(this);
|
|
|
|
this._gtz.dispose();
|
|
|
|
this._gtz = null;
|
|
|
|
return this;
|
|
|
|
};
|
2014-07-04 02:59:16 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
export default Tone.GreaterThan;
|
2018-06-06 01:53:28 +00:00
|
|
|
|