Tone.js/Tone/signal/AND.js

61 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-10-03 21:20:00 +00:00
define(["Tone/core/Tone", "Tone/signal/Equal"], function(Tone){
"use strict";
/**
* @class and returns 1 when all the inputs are equal to 1
*
* @extends {Tone}
* @constructor
* @param {number} [inputCount=2] the number of inputs. NOTE: all inputs are
* connected to the single AND input node
*/
Tone.AND = function(inputCount){
2014-10-30 05:05:17 +00:00
inputCount = this.defaultArg(inputCount, 2);
/**
* the inputs
* @type {Array}
*/
this.input = new Array(inputCount);
2014-10-03 21:20:00 +00:00
/**
* @type {Tone.Equal}
* @private
*/
2014-10-30 05:05:17 +00:00
this._equals = new Tone.Equal(inputCount);
2014-10-03 21:20:00 +00:00
/**
2014-10-30 05:05:17 +00:00
* the output
2014-10-03 21:20:00 +00:00
* @type {Tone.Equal}
*/
2014-10-30 05:05:17 +00:00
this.output = this._equals;
//make each of the inputs an alias
for (var i = 0; i < inputCount; i++){
this.input[i] = this._equals;
}
2014-10-03 21:20:00 +00:00
};
Tone.extend(Tone.AND);
/**
* the number of inputs to consider
* @param {number} inputCount
*/
Tone.AND.prototype.setInputCount = function(inputCount){
this._equals.setValue(inputCount);
};
/**
* clean up
*/
Tone.AND.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
this._equals.dispose();
this._equals = null;
};
return Tone.AND;
});