Tone.js/Tone/signal/Negate.js

38 lines
866 B
JavaScript
Raw Normal View History

2014-08-24 19:47:59 +00:00
define(["Tone/core/Tone", "Tone/signal/Multiply", "Tone/signal/Signal"], function(Tone){
2014-07-02 21:08:59 +00:00
"use strict";
2014-07-02 21:08:59 +00:00
/**
2014-07-04 17:47:56 +00:00
* @class Negate the incoming signal. i.e. an input signal of 10 will output -10
2014-07-02 21:08:59 +00:00
*
* @constructor
* @extends {Tone.SignalBase}
2015-02-27 18:40:35 +00:00
* @example
2015-06-14 05:17:09 +00:00
* var neg = new Tone.Negate();
* var sig = new Tone.Signal(-2).connect(neg);
* //output of neg is positive 2.
2014-07-02 21:08:59 +00:00
*/
2014-07-22 16:48:22 +00:00
Tone.Negate = function(){
2014-07-02 21:08:59 +00:00
/**
* negation is done by multiplying by -1
* @type {Tone.Multiply}
* @private
*/
2015-04-05 18:01:05 +00:00
this._multiply = this.input = this.output = new Tone.Multiply(-1);
2014-07-02 21:08:59 +00:00
};
Tone.extend(Tone.Negate, Tone.SignalBase);
2014-07-02 21:08:59 +00:00
/**
* clean up
* @returns {Tone.Negate} this
2014-07-02 21:08:59 +00:00
*/
Tone.Negate.prototype.dispose = function(){
Tone.prototype.dispose.call(this);
this._multiply.dispose();
this._multiply = null;
2015-02-02 03:56:33 +00:00
return this;
2014-07-02 21:08:59 +00:00
};
return Tone.Negate;
});