mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-28 04:23:15 +00:00
aaf880c925
* WIP moving tests to web-test-runner * updating thresholds * Adding file extensions * Testing integrations * linting * fixing dep * moving back to root dir * prettier all of the files * updating eslint rules to use with prettier * remove import package * moving tsignore around * removing unneeded ignores * all tests run on puppeteer, no need for testing guards * linting * import type syntax * cleaning up * Update package.json
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import { Gain } from "../core/context/Gain.js";
|
|
import {
|
|
connect,
|
|
disconnect,
|
|
ToneAudioNodeOptions,
|
|
} from "../core/context/ToneAudioNode.js";
|
|
import { optionsFromArguments } from "../core/util/Defaults.js";
|
|
import { SignalOperator } from "./SignalOperator.js";
|
|
|
|
/**
|
|
* Tone.Zero outputs 0's at audio-rate. The reason this has to be
|
|
* it's own class is that many browsers optimize out Tone.Signal
|
|
* with a value of 0 and will not process nodes further down the graph.
|
|
* @category Signal
|
|
*/
|
|
export class Zero extends SignalOperator<ToneAudioNodeOptions> {
|
|
readonly name: string = "Zero";
|
|
|
|
/**
|
|
* The gain node which connects the constant source to the output
|
|
*/
|
|
private _gain = new Gain({ context: this.context });
|
|
|
|
/**
|
|
* Only outputs 0
|
|
*/
|
|
output = this._gain;
|
|
|
|
/**
|
|
* no input node
|
|
*/
|
|
input = undefined;
|
|
|
|
constructor(options?: Partial<ToneAudioNodeOptions>);
|
|
constructor() {
|
|
super(
|
|
Object.assign(optionsFromArguments(Zero.getDefaults(), arguments))
|
|
);
|
|
connect(this.context.getConstant(0), this._gain);
|
|
}
|
|
|
|
/**
|
|
* clean up
|
|
*/
|
|
dispose(): this {
|
|
super.dispose();
|
|
disconnect(this.context.getConstant(0), this._gain);
|
|
return this;
|
|
}
|
|
}
|