1 | import { AudioRange, Cents, Degrees, Frequency, Positive } from "../../core/type/Units.js";
|
2 | import { Omit } from "../../core/util/Interface.js";
|
3 | import { Signal } from "../../signal/Signal.js";
|
4 | import { SourceOptions } from "../Source.js";
|
5 |
|
6 |
|
7 |
|
8 | export interface ToneOscillatorInterface {
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | baseType: OscillatorType | "pulse" | "pwm";
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | type: ExtendedToneOscillatorType;
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | readonly frequency: Signal<"frequency">;
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | readonly detune: Signal<"cents">;
|
46 | |
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | phase: Degrees;
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | partials: number[];
|
74 | |
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | partialCount?: number;
|
90 | |
91 |
|
92 |
|
93 |
|
94 | asArray(length: number): Promise<Float32Array>;
|
95 | }
|
96 |
|
97 |
|
98 |
|
99 | export declare function generateWaveform(instance: any, length: number): Promise<Float32Array>;
|
100 |
|
101 |
|
102 |
|
103 | type PartialsRange = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32;
|
104 |
|
105 |
|
106 |
|
107 | type SineWithPartials = `sine${PartialsRange}`;
|
108 | type SquareWithPartials = `square${PartialsRange}`;
|
109 | type SawtoothWithPartials = `sawtooth${PartialsRange}`;
|
110 | type TriangleWithPartials = `triangle${PartialsRange}`;
|
111 | type TypeWithPartials = SineWithPartials | SquareWithPartials | TriangleWithPartials | SawtoothWithPartials;
|
112 | interface BaseOscillatorOptions extends SourceOptions {
|
113 | frequency: Frequency;
|
114 | detune: Cents;
|
115 | phase: Degrees;
|
116 | }
|
117 | export type NonCustomOscillatorType = Exclude<OscillatorType, "custom">;
|
118 | type AllNonCustomOscillatorType = NonCustomOscillatorType | TypeWithPartials;
|
119 | export type ToneOscillatorType = AllNonCustomOscillatorType | "custom";
|
120 | export type ExtendedToneOscillatorType = ToneOscillatorType | "pwm" | "pulse";
|
121 |
|
122 |
|
123 |
|
124 | interface ToneCustomOscillatorOptions extends BaseOscillatorOptions {
|
125 | type: "custom";
|
126 | partials: number[];
|
127 | }
|
128 | interface ToneTypeOscillatorOptions extends BaseOscillatorOptions {
|
129 | type: NonCustomOscillatorType;
|
130 | partialCount?: number;
|
131 | }
|
132 | interface TonePartialOscillatorOptions extends BaseOscillatorOptions {
|
133 | type: TypeWithPartials;
|
134 | }
|
135 | export type ToneOscillatorConstructorOptions = ToneCustomOscillatorOptions | ToneTypeOscillatorOptions | TonePartialOscillatorOptions;
|
136 | export interface ToneOscillatorOptions extends BaseOscillatorOptions {
|
137 | type: ToneOscillatorType;
|
138 | partialCount: number;
|
139 | partials: number[];
|
140 | }
|
141 |
|
142 |
|
143 |
|
144 | interface FMBaseOscillatorOptions extends BaseOscillatorOptions {
|
145 | harmonicity: Positive;
|
146 | modulationIndex: Positive;
|
147 | modulationType: AllNonCustomOscillatorType;
|
148 | }
|
149 | interface FMCustomOscillatorOptions extends FMBaseOscillatorOptions {
|
150 | type: "custom";
|
151 | partials: number[];
|
152 | }
|
153 | interface FMTypeOscillatorOptions extends FMBaseOscillatorOptions {
|
154 | type: NonCustomOscillatorType;
|
155 | partialsCount?: number;
|
156 | }
|
157 | interface FMPartialsOscillatorOptions extends FMBaseOscillatorOptions {
|
158 | type: TypeWithPartials;
|
159 | }
|
160 | export type FMConstructorOptions = FMTypeOscillatorOptions | FMCustomOscillatorOptions | FMPartialsOscillatorOptions;
|
161 | export interface FMOscillatorOptions extends ToneOscillatorOptions {
|
162 | harmonicity: Positive;
|
163 | modulationIndex: Positive;
|
164 | modulationType: AllNonCustomOscillatorType;
|
165 | }
|
166 |
|
167 |
|
168 |
|
169 | interface AMBaseOscillatorOptions extends BaseOscillatorOptions {
|
170 | harmonicity: Positive;
|
171 | modulationType: AllNonCustomOscillatorType;
|
172 | }
|
173 | interface AMCustomOscillatorOptions extends AMBaseOscillatorOptions {
|
174 | type: "custom";
|
175 | partials: number[];
|
176 | }
|
177 | interface AMTypeOscillatorOptions extends AMBaseOscillatorOptions {
|
178 | type: NonCustomOscillatorType;
|
179 | partialsCount?: number;
|
180 | }
|
181 | interface AMPartialsOscillatorOptions extends AMBaseOscillatorOptions {
|
182 | type: TypeWithPartials;
|
183 | }
|
184 | export type AMConstructorOptions = AMCustomOscillatorOptions | AMTypeOscillatorOptions | AMPartialsOscillatorOptions;
|
185 | export interface AMOscillatorOptions extends ToneOscillatorOptions {
|
186 | harmonicity: Positive;
|
187 | modulationType: AllNonCustomOscillatorType;
|
188 | }
|
189 |
|
190 |
|
191 |
|
192 | interface FatBaseOscillatorOptions extends BaseOscillatorOptions {
|
193 | spread: Cents;
|
194 | count: Positive;
|
195 | }
|
196 | interface FatCustomOscillatorOptions extends FatBaseOscillatorOptions {
|
197 | type: "custom";
|
198 | partials: number[];
|
199 | }
|
200 | interface FatTypeOscillatorOptions extends FatBaseOscillatorOptions {
|
201 | type: NonCustomOscillatorType;
|
202 | partialCount?: number;
|
203 | }
|
204 | interface FatPartialsOscillatorOptions extends FatBaseOscillatorOptions {
|
205 | type: TypeWithPartials;
|
206 | }
|
207 | export type FatConstructorOptions = FatCustomOscillatorOptions | FatTypeOscillatorOptions | FatPartialsOscillatorOptions;
|
208 | export interface FatOscillatorOptions extends ToneOscillatorOptions {
|
209 | spread: Cents;
|
210 | count: Positive;
|
211 | }
|
212 |
|
213 |
|
214 |
|
215 | export interface PulseOscillatorOptions extends BaseOscillatorOptions {
|
216 | type: "pulse";
|
217 | width: AudioRange;
|
218 | }
|
219 |
|
220 |
|
221 |
|
222 | export interface PWMOscillatorOptions extends BaseOscillatorOptions {
|
223 | type: "pwm";
|
224 | modulationFrequency: Frequency;
|
225 | }
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 | type FMSineWithPartials = `fmsine${PartialsRange}`;
|
233 | type FMSquareWithPartials = `fmsquare${PartialsRange}`;
|
234 | type FMSawtoothWithPartials = `fmsawtooth${PartialsRange}`;
|
235 | type FMTriangleWithPartials = `fmtriangle${PartialsRange}`;
|
236 | type FMTypeWithPartials = FMSineWithPartials | FMSquareWithPartials | FMSawtoothWithPartials | FMTriangleWithPartials;
|
237 |
|
238 |
|
239 |
|
240 | type AMSineWithPartials = `amsine${PartialsRange}`;
|
241 | type AMSquareWithPartials = `amsquare${PartialsRange}`;
|
242 | type AMSawtoothWithPartials = `amsawtooth${PartialsRange}`;
|
243 | type AMTriangleWithPartials = `amtriangle${PartialsRange}`;
|
244 | type AMTypeWithPartials = AMSineWithPartials | AMSquareWithPartials | AMSawtoothWithPartials | AMTriangleWithPartials;
|
245 |
|
246 |
|
247 |
|
248 | type FatSineWithPartials = `fatsine${PartialsRange}`;
|
249 | type FatSquareWithPartials = `fatsquare${PartialsRange}`;
|
250 | type FatSawtoothWithPartials = `fatsawtooth${PartialsRange}`;
|
251 | type FatTriangleWithPartials = `fattriangle${PartialsRange}`;
|
252 | type FatTypeWithPartials = FatSineWithPartials | FatSquareWithPartials | FatSawtoothWithPartials | FatTriangleWithPartials;
|
253 |
|
254 |
|
255 |
|
256 | interface OmniFMCustomOscillatorOptions extends FMBaseOscillatorOptions {
|
257 | type: "fmcustom";
|
258 | partials: number[];
|
259 | }
|
260 | interface OmniFMTypeOscillatorOptions extends FMBaseOscillatorOptions {
|
261 | type: "fmsine" | "fmsquare" | "fmsawtooth" | "fmtriangle";
|
262 | partialsCount?: number;
|
263 | }
|
264 | interface OmniFMPartialsOscillatorOptions extends FMBaseOscillatorOptions {
|
265 | type: FMTypeWithPartials;
|
266 | }
|
267 |
|
268 |
|
269 |
|
270 | interface OmniAMCustomOscillatorOptions extends AMBaseOscillatorOptions {
|
271 | type: "amcustom";
|
272 | partials: number[];
|
273 | }
|
274 | interface OmniAMTypeOscillatorOptions extends AMBaseOscillatorOptions {
|
275 | type: "amsine" | "amsquare" | "amsawtooth" | "amtriangle";
|
276 | partialsCount?: number;
|
277 | }
|
278 | interface OmniAMPartialsOscillatorOptions extends AMBaseOscillatorOptions {
|
279 | type: AMTypeWithPartials;
|
280 | }
|
281 |
|
282 |
|
283 |
|
284 | interface OmniFatCustomOscillatorOptions extends FatBaseOscillatorOptions {
|
285 | type: "fatcustom";
|
286 | partials: number[];
|
287 | }
|
288 | interface OmniFatTypeOscillatorOptions extends FatBaseOscillatorOptions {
|
289 | type: "fatsine" | "fatsquare" | "fatsawtooth" | "fattriangle";
|
290 | partialsCount?: number;
|
291 | }
|
292 | interface OmniFatPartialsOscillatorOptions extends FatBaseOscillatorOptions {
|
293 | type: FatTypeWithPartials;
|
294 | }
|
295 | export type OmniOscillatorType = "fatsine" | "fatsquare" | "fatsawtooth" | "fattriangle" | "fatcustom" | FatTypeWithPartials | "fmsine" | "fmsquare" | "fmsawtooth" | "fmtriangle" | "fmcustom" | FMTypeWithPartials | "amsine" | "amsquare" | "amsawtooth" | "amtriangle" | "amcustom" | AMTypeWithPartials | TypeWithPartials | OscillatorType | "pulse" | "pwm";
|
296 | export type OmniOscillatorOptions = PulseOscillatorOptions | PWMOscillatorOptions | OmniFatCustomOscillatorOptions | OmniFatTypeOscillatorOptions | OmniFatPartialsOscillatorOptions | OmniFMCustomOscillatorOptions | OmniFMTypeOscillatorOptions | OmniFMPartialsOscillatorOptions | OmniAMCustomOscillatorOptions | OmniAMTypeOscillatorOptions | OmniAMPartialsOscillatorOptions | ToneOscillatorConstructorOptions;
|
297 | type OmitSourceOptions<T extends BaseOscillatorOptions> = Omit<T, "frequency" | "detune" | "context">;
|
298 |
|
299 |
|
300 |
|
301 | export type OmniOscillatorSynthOptions = OmitSourceOptions<PulseOscillatorOptions> | OmitSourceOptions<PWMOscillatorOptions> | OmitSourceOptions<OmniFatCustomOscillatorOptions> | OmitSourceOptions<OmniFatTypeOscillatorOptions> | OmitSourceOptions<OmniFatPartialsOscillatorOptions> | OmitSourceOptions<OmniFMCustomOscillatorOptions> | OmitSourceOptions<OmniFMTypeOscillatorOptions> | OmitSourceOptions<OmniFMPartialsOscillatorOptions> | OmitSourceOptions<OmniAMCustomOscillatorOptions> | OmitSourceOptions<OmniAMTypeOscillatorOptions> | OmitSourceOptions<OmniAMPartialsOscillatorOptions> | OmitSourceOptions<ToneCustomOscillatorOptions> | OmitSourceOptions<ToneTypeOscillatorOptions> | OmitSourceOptions<TonePartialOscillatorOptions>;
|
302 | export {};
|