2019-01-27 18:05:20 +00:00
|
|
|
import Tone from "../core/Tone";
|
|
|
|
import "../signal/Multiply";
|
|
|
|
import "../signal/Signal";
|
2014-07-02 21:08:59 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* @class Negate the incoming signal. i.e. an input signal of 10 will output -10
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @extends {Tone.SignalBase}
|
|
|
|
* @example
|
|
|
|
* var neg = new Tone.Negate();
|
|
|
|
* var sig = new Tone.Signal(-2).connect(neg);
|
|
|
|
* //output of neg is positive 2.
|
|
|
|
*/
|
|
|
|
Tone.Negate = function(){
|
2014-09-04 04:41:40 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.SignalBase.call(this);
|
2014-07-02 21:08:59 +00:00
|
|
|
/**
|
2019-01-27 18:05:20 +00:00
|
|
|
* negation is done by multiplying by -1
|
|
|
|
* @type {Tone.Multiply}
|
|
|
|
* @private
|
2014-07-02 21:08:59 +00:00
|
|
|
*/
|
2019-01-27 18:05:20 +00:00
|
|
|
this._multiply = this.input = this.output = new Tone.Multiply(-1);
|
|
|
|
};
|
2017-04-26 03:45:37 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Tone.extend(Tone.Negate, Tone.SignalBase);
|
2014-07-02 21:08:59 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
/**
|
|
|
|
* clean up
|
|
|
|
* @returns {Tone.Negate} this
|
|
|
|
*/
|
|
|
|
Tone.Negate.prototype.dispose = function(){
|
|
|
|
Tone.SignalBase.prototype.dispose.call(this);
|
|
|
|
this._multiply.dispose();
|
|
|
|
this._multiply = null;
|
|
|
|
return this;
|
|
|
|
};
|
2014-08-24 17:19:49 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
export default Tone.Negate;
|
2014-07-02 21:08:59 +00:00
|
|
|
|