Tone.js/Tone/signal/GainToAudio.ts
Yotam Mann aaf880c925
Using web-test-runner for tests, updating import paths (#1242)
* 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
2024-05-03 14:31:14 -04:00

39 lines
816 B
TypeScript

import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
import { SignalOperator } from "./SignalOperator.js";
import { WaveShaper } from "./WaveShaper.js";
/**
* GainToAudio converts an input in NormalRange [0,1] to AudioRange [-1,1].
* @see {@link AudioToGain}.
* @category Signal
*/
export class GainToAudio extends SignalOperator<ToneAudioNodeOptions> {
readonly name: string = "GainToAudio";
/**
* The node which converts the audio ranges
*/
private _norm = new WaveShaper({
context: this.context,
mapping: (x) => Math.abs(x) * 2 - 1,
});
/**
* The NormalRange input [0, 1]
*/
input = this._norm;
/**
* The AudioRange output [-1, 1]
*/
output = this._norm;
/**
* clean up
*/
dispose(): this {
super.dispose();
this._norm.dispose();
return this;
}
}