Tone.js/Tone/signal/OR.js
2014-10-30 01:05:17 -04:00

62 lines
No EOL
1.1 KiB
JavaScript

define(["Tone/core/Tone", "Tone/signal/GreaterThanZero"], function(Tone){
"use strict";
/**
* @class OR the inputs together. True if at least one of the inputs is true.
* Simply an alias for Tone.GreaterThanZero
*
* @extends {Tone}
* @constructor
*/
Tone.OR = function(inputCount){
inputCount = this.defaultArg(inputCount, 2);
/**
* the inputs
* @type {Array}
*/
this.input = new Array(inputCount);
/**
* a private summing node
* @type {GainNode}
* @private
*/
this._sum = this.context.createGain();
/**
* @type {Tone.Equal}
* @private
*/
this._gtz = new Tone.GreaterThanZero();
/**
* the output
* @type {Tone.Equal}
*/
this.output = this._gtz;
//make each of the inputs an alias
for (var i = 0; i < inputCount; i++){
this.input[i] = this._sum;
}
this._sum.connect(this._gtz);
};
Tone.extend(Tone.OR);
/**
* clean up
*/
Tone.OR.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
this._gtz.dispose();
this._gtz = null;
this._sum.disconnect();
this._sum = null;
};
return Tone.OR;
});