UNPKG

1.79 kBTypeScriptView Raw
1import { Param } from "../context/Param.js";
2import { UnitMap, UnitName } from "../type/Units.js";
3import { ToneAudioNode, ToneAudioNodeOptions } from "./ToneAudioNode.js";
4interface GainOptions<TypeName extends UnitName> extends ToneAudioNodeOptions {
5 gain: UnitMap[TypeName];
6 units: TypeName;
7 convert: boolean;
8 minValue?: number;
9 maxValue?: number;
10}
11/**
12 * A thin wrapper around the Native Web Audio GainNode.
13 * The GainNode is a basic building block of the Web Audio
14 * API and is useful for routing audio and adjusting gains.
15 * @category Core
16 * @example
17 * return Tone.Offline(() => {
18 * const gainNode = new Tone.Gain(0).toDestination();
19 * const osc = new Tone.Oscillator(30).connect(gainNode).start();
20 * gainNode.gain.rampTo(1, 0.1);
21 * gainNode.gain.rampTo(0, 0.4, 0.2);
22 * }, 0.7, 1);
23 */
24export declare class Gain<TypeName extends "gain" | "decibels" | "normalRange" = "gain"> extends ToneAudioNode<GainOptions<TypeName>> {
25 readonly name: string;
26 /**
27 * The gain parameter of the gain node.
28 * @example
29 * const gainNode = new Tone.Gain(0).toDestination();
30 * const osc = new Tone.Oscillator().connect(gainNode).start();
31 * gainNode.gain.rampTo(1, 0.1);
32 * gainNode.gain.rampTo(0, 2, "+0.5");
33 */
34 readonly gain: Param<TypeName>;
35 /**
36 * The wrapped GainNode.
37 */
38 private _gainNode;
39 readonly input: GainNode;
40 readonly output: GainNode;
41 /**
42 * @param gain The initial gain of the GainNode
43 * @param units The units of the gain parameter.
44 */
45 constructor(gain?: UnitMap[TypeName], units?: TypeName);
46 constructor(options?: Partial<GainOptions<TypeName>>);
47 static getDefaults(): GainOptions<any>;
48 /**
49 * Clean up.
50 */
51 dispose(): this;
52}
53export {};