Tone.js/Tone/signal/Negate.ts
Yotam Mann 56db8b3a7a simplifying _internalChannels
channelCount/Mode/Interpretation check the input/output nodes, which removes the need for many classes to have _internalChannels
2019-08-03 12:00:14 -04:00

43 lines
966 B
TypeScript

import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode";
import { optionsFromArguments } from "../core/util/Defaults";
import { Multiply } from "./Multiply";
import { SignalOperator } from "./SignalOperator";
/**
* @class Negate the incoming signal. i.e. an input signal of 10 will output -10
*
* @constructor
* @extends {Tone.SignalBase}
* @example
* var neg = new Negate();
* var sig = new Signal(-2).connect(neg);
* //output of neg is positive 2.
*/
export class Negate extends SignalOperator<ToneAudioNodeOptions> {
name = "Negate";
/**
* negation is done by multiplying by -1
*/
private _multiply: Multiply = new Multiply({
context: this.context,
value: -1,
});
/**
* The input and output are equal to the multiply node
*/
input = this._multiply;
output = this._multiply;
/**
* clean up
* @returns {Negate} this
*/
dispose(): this {
super.dispose();
this._multiply.dispose();
return this;
}
}