UNPKG

950 BJavaScriptView Raw
1import { SignalOperator } from "./SignalOperator.js";
2import { WaveShaper } from "./WaveShaper.js";
3/**
4 * GainToAudio converts an input in NormalRange [0,1] to AudioRange [-1,1].
5 * @see {@link AudioToGain}.
6 * @category Signal
7 */
8export class GainToAudio extends SignalOperator {
9 constructor() {
10 super(...arguments);
11 this.name = "GainToAudio";
12 /**
13 * The node which converts the audio ranges
14 */
15 this._norm = new WaveShaper({
16 context: this.context,
17 mapping: (x) => Math.abs(x) * 2 - 1,
18 });
19 /**
20 * The NormalRange input [0, 1]
21 */
22 this.input = this._norm;
23 /**
24 * The AudioRange output [-1, 1]
25 */
26 this.output = this._norm;
27 }
28 /**
29 * clean up
30 */
31 dispose() {
32 super.dispose();
33 this._norm.dispose();
34 return this;
35 }
36}
37//# sourceMappingURL=GainToAudio.js.map
\No newline at end of file