1 | import { AbstractParam } from "../context/AbstractParam.js";
|
2 | import { Positive, Time, UnitMap, UnitName } from "../type/Units.js";
|
3 | import { Timeline } from "../util/Timeline.js";
|
4 | import { ToneWithContext, ToneWithContextOptions } from "./ToneWithContext.js";
|
5 | export interface ParamOptions<TypeName extends UnitName> extends ToneWithContextOptions {
|
6 | units: TypeName;
|
7 | value?: UnitMap[TypeName];
|
8 | param: AudioParam | Param<TypeName>;
|
9 | convert: boolean;
|
10 | minValue?: number;
|
11 | maxValue?: number;
|
12 | swappable?: boolean;
|
13 | }
|
14 |
|
15 |
|
16 |
|
17 | type AutomationType = "linearRampToValueAtTime" | "exponentialRampToValueAtTime" | "setValueAtTime" | "setTargetAtTime" | "cancelScheduledValues";
|
18 | interface TargetAutomationEvent {
|
19 | type: "setTargetAtTime";
|
20 | time: number;
|
21 | value: number;
|
22 | constant: number;
|
23 | }
|
24 | interface NormalAutomationEvent {
|
25 | type: Exclude<AutomationType, "setTargetAtTime">;
|
26 | time: number;
|
27 | value: number;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | export type AutomationEvent = NormalAutomationEvent | TargetAutomationEvent;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | export declare class Param<TypeName extends UnitName = "number"> extends ToneWithContext<ParamOptions<TypeName>> implements AbstractParam<TypeName> {
|
41 | readonly name: string;
|
42 | readonly input: GainNode | AudioParam;
|
43 | readonly units: UnitName;
|
44 | convert: boolean;
|
45 | overridden: boolean;
|
46 | |
47 |
|
48 |
|
49 | protected _events: Timeline<AutomationEvent>;
|
50 | |
51 |
|
52 |
|
53 | protected _param: AudioParam;
|
54 | |
55 |
|
56 |
|
57 | protected _initialValue: number;
|
58 | |
59 |
|
60 |
|
61 | private _minOutput;
|
62 | |
63 |
|
64 |
|
65 | private readonly _minValue?;
|
66 | private readonly _maxValue?;
|
67 | |
68 |
|
69 |
|
70 |
|
71 | protected readonly _swappable: boolean;
|
72 | |
73 |
|
74 |
|
75 |
|
76 |
|
77 | constructor(param: AudioParam, units?: TypeName, convert?: boolean);
|
78 | constructor(options: Partial<ParamOptions<TypeName>>);
|
79 | static getDefaults(): ParamOptions<any>;
|
80 | get value(): UnitMap[TypeName];
|
81 | set value(value: UnitMap[TypeName]);
|
82 | get minValue(): number;
|
83 | get maxValue(): number;
|
84 | /**
|
85 | * Type guard based on the unit name
|
86 | */
|
87 | private _is;
|
88 | /**
|
89 | * Make sure the value is always in the defined range
|
90 | */
|
91 | private _assertRange;
|
92 | /**
|
93 | * Convert the given value from the type specified by Param.units
|
94 | * into the destination value (such as Gain or Frequency).
|
95 | */
|
96 | protected _fromType(val: UnitMap[TypeName]): number;
|
97 | /**
|
98 | * Convert the parameters value into the units specified by Param.units.
|
99 | */
|
100 | protected _toType(val: number): UnitMap[TypeName];
|
101 | setValueAtTime(value: UnitMap[TypeName], time: Time): this;
|
102 | getValueAtTime(time: Time): UnitMap[TypeName];
|
103 | setRampPoint(time: Time): this;
|
104 | linearRampToValueAtTime(value: UnitMap[TypeName], endTime: Time): this;
|
105 | exponentialRampToValueAtTime(value: UnitMap[TypeName], endTime: Time): this;
|
106 | exponentialRampTo(value: UnitMap[TypeName], rampTime: Time, startTime?: Time): this;
|
107 | linearRampTo(value: UnitMap[TypeName], rampTime: Time, startTime?: Time): this;
|
108 | targetRampTo(value: UnitMap[TypeName], rampTime: Time, startTime?: Time): this;
|
109 | exponentialApproachValueAtTime(value: UnitMap[TypeName], time: Time, rampTime: Time): this;
|
110 | setTargetAtTime(value: UnitMap[TypeName], startTime: Time, timeConstant: Positive): this;
|
111 | setValueCurveAtTime(values: UnitMap[TypeName][], startTime: Time, duration: Time, scaling?: number): this;
|
112 | cancelScheduledValues(time: Time): this;
|
113 | cancelAndHoldAtTime(time: Time): this;
|
114 | rampTo(value: UnitMap[TypeName], rampTime?: Time, startTime?: Time): this;
|
115 | /**
|
116 | * Apply all of the previously scheduled events to the passed in Param or AudioParam.
|
117 | * The applied values will start at the context's current time and schedule
|
118 | * all of the events which are scheduled on this Param onto the passed in param.
|
119 | */
|
120 | apply(param: Param | AudioParam): this;
|
121 | /**
|
122 | * Replace the Param's internal AudioParam. Will apply scheduled curves
|
123 | * onto the parameter and replace the connections.
|
124 | */
|
125 | setParam(param: AudioParam): this;
|
126 | dispose(): this;
|
127 | get defaultValue(): UnitMap[TypeName];
|
128 | protected _exponentialApproach(t0: number, v0: number, v1: number, timeConstant: number, t: number): number;
|
129 | protected _linearInterpolate(t0: number, v0: number, t1: number, v1: number, t: number): number;
|
130 | protected _exponentialInterpolate(t0: number, v0: number, t1: number, v1: number, t: number): number;
|
131 | }
|
132 | export {};
|