2014-10-03 17:07:26 +00:00
|
|
|
define(["Tone/core/Tone", "Tone/signal/GreaterThan", "Tone/signal/Negate"], 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-07-04 17:47:56 +00:00
|
|
|
* @class Output 1 if the signal is less than the value, otherwise outputs 0
|
2014-07-04 02:59:16 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone}
|
2014-07-20 22:17:01 +00:00
|
|
|
* @param {number=} [value=0] the value to compare to the incoming signal
|
2014-07-04 02:59:16 +00:00
|
|
|
*/
|
|
|
|
Tone.LessThan = function(value){
|
2014-09-08 02:16:19 +00:00
|
|
|
|
2014-07-04 02:59:16 +00:00
|
|
|
/**
|
2014-10-03 17:07:26 +00:00
|
|
|
* negate the incoming signal
|
|
|
|
* @type {Tone.Negate}
|
2014-07-20 22:17:01 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2014-10-03 17:07:26 +00:00
|
|
|
this._neg = new Tone.Negate();
|
2014-07-20 22:17:01 +00:00
|
|
|
|
|
|
|
/**
|
2014-10-03 17:07:26 +00:00
|
|
|
* input < value === -input > -value
|
|
|
|
* @type {Tone.GreaterThan}
|
2014-07-20 22:17:01 +00:00
|
|
|
* @private
|
|
|
|
*/
|
2014-10-03 17:07:26 +00:00
|
|
|
this._gt = new Tone.GreaterThan(-value);
|
2014-07-04 02:59:16 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-20 22:17:01 +00:00
|
|
|
* alias for the adder
|
2014-10-03 17:07:26 +00:00
|
|
|
* @type {Tone.Negate}
|
2014-07-04 02:59:16 +00:00
|
|
|
*/
|
2014-10-03 17:07:26 +00:00
|
|
|
this.input = this._neg;
|
2014-07-20 22:17:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* alias for the thresh
|
2014-10-03 17:07:26 +00:00
|
|
|
* @type {Tone.GreatThan}
|
2014-07-20 22:17:01 +00:00
|
|
|
*/
|
2014-10-03 17:07:26 +00:00
|
|
|
this.output = this._gt;
|
2014-07-20 22:17:01 +00:00
|
|
|
|
|
|
|
//connect
|
2014-10-03 17:07:26 +00:00
|
|
|
this._neg.connect(this._gt);
|
2014-07-04 02:59:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Tone.extend(Tone.LessThan);
|
|
|
|
|
2014-07-20 22:17:01 +00:00
|
|
|
/**
|
|
|
|
* set the value to compare to
|
|
|
|
*
|
2014-07-04 02:59:16 +00:00
|
|
|
* @param {number} value
|
|
|
|
*/
|
|
|
|
Tone.LessThan.prototype.setValue = function(value){
|
2014-10-03 17:07:26 +00:00
|
|
|
this._gt.setValue(-value);
|
2014-07-04 02:59:16 +00:00
|
|
|
};
|
|
|
|
|
2014-08-24 17:19:49 +00:00
|
|
|
/**
|
|
|
|
* borrows the method from {@link Tone.Signal}
|
|
|
|
*
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
Tone.LessThan.prototype.connect = Tone.Signal.prototype.connect;
|
|
|
|
|
2014-07-04 02:59:16 +00:00
|
|
|
/**
|
|
|
|
* dispose method
|
|
|
|
*/
|
|
|
|
Tone.LessThan.prototype.dispose = function(){
|
2014-09-06 22:55:11 +00:00
|
|
|
Tone.prototype.dispose.call(this);
|
2014-10-03 17:07:26 +00:00
|
|
|
this._neg.dispose();
|
|
|
|
this._gt.dispose();
|
|
|
|
this._neg = null;
|
|
|
|
this._gt = null;
|
2014-07-04 02:59:16 +00:00
|
|
|
};
|
|
|
|
|
2014-07-20 22:17:01 +00:00
|
|
|
return Tone.LessThan;
|
2014-07-04 02:59:16 +00:00
|
|
|
});
|