1 | import { Cents, Degrees, Frequency, Seconds, Time } from "../../core/type/Units.js";
|
2 | import { Signal } from "../../signal/Signal.js";
|
3 | import { Source } from "../Source.js";
|
4 | import { AMOscillator } from "./AMOscillator.js";
|
5 | import { FatOscillator } from "./FatOscillator.js";
|
6 | import { FMOscillator } from "./FMOscillator.js";
|
7 | import { Oscillator } from "./Oscillator.js";
|
8 | import { OmniOscillatorOptions, OmniOscillatorType, ToneOscillatorInterface, ToneOscillatorType } from "./OscillatorInterface.js";
|
9 | import { PulseOscillator } from "./PulseOscillator.js";
|
10 | import { PWMOscillator } from "./PWMOscillator.js";
|
11 | export { OmniOscillatorOptions } from "./OscillatorInterface.js";
|
12 |
|
13 |
|
14 |
|
15 | type AnyOscillator = Oscillator | PWMOscillator | PulseOscillator | FatOscillator | AMOscillator | FMOscillator;
|
16 |
|
17 |
|
18 |
|
19 | interface OmniOscillatorSource {
|
20 | fm: FMOscillator;
|
21 | am: AMOscillator;
|
22 | pwm: PWMOscillator;
|
23 | pulse: PulseOscillator;
|
24 | oscillator: Oscillator;
|
25 | fat: FatOscillator;
|
26 | }
|
27 |
|
28 |
|
29 |
|
30 | export type OmniOscSourceType = keyof OmniOscillatorSource;
|
31 | type IsAmOrFmOscillator<Osc, Ret> = Osc extends AMOscillator ? Ret : Osc extends FMOscillator ? Ret : undefined;
|
32 | type IsFatOscillator<Osc, Ret> = Osc extends FatOscillator ? Ret : undefined;
|
33 | type IsPWMOscillator<Osc, Ret> = Osc extends PWMOscillator ? Ret : undefined;
|
34 | type IsPulseOscillator<Osc, Ret> = Osc extends PulseOscillator ? Ret : undefined;
|
35 | type IsFMOscillator<Osc, Ret> = Osc extends FMOscillator ? Ret : undefined;
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | export declare class OmniOscillator<OscType extends AnyOscillator> extends Source<OmniOscillatorOptions> implements Omit<ToneOscillatorInterface, "type"> {
|
45 | readonly name: string;
|
46 | readonly frequency: Signal<"frequency">;
|
47 | readonly detune: Signal<"cents">;
|
48 | |
49 |
|
50 |
|
51 | private _oscillator;
|
52 | |
53 |
|
54 |
|
55 | private _sourceType;
|
56 | |
57 |
|
58 |
|
59 |
|
60 | constructor(frequency?: Frequency, type?: OmniOscillatorType);
|
61 | constructor(options?: Partial<OmniOscillatorOptions>);
|
62 | static getDefaults(): OmniOscillatorOptions;
|
63 | /**
|
64 | * start the oscillator
|
65 | */
|
66 | protected _start(time: Time): void;
|
67 | /**
|
68 | * start the oscillator
|
69 | */
|
70 | protected _stop(time: Time): void;
|
71 | protected _restart(time: Seconds): this;
|
72 | /**
|
73 | * The type of the oscillator. Can be any of the basic types: sine, square, triangle, sawtooth. Or
|
74 | * prefix the basic types with "fm", "am", or "fat" to use the FMOscillator, AMOscillator or FatOscillator
|
75 | * types. The oscillator could also be set to "pwm" or "pulse". All of the parameters of the
|
76 | * oscillator's class are accessible when the oscillator is set to that type, but throws an error
|
77 | * when it's not.
|
78 | * @example
|
79 | * const omniOsc = new Tone.OmniOscillator().toDestination().start();
|
80 | * omniOsc.type = "pwm";
|
81 | * // modulationFrequency is parameter which is available
|
82 | * // only when the type is "pwm".
|
83 | * omniOsc.modulationFrequency.value = 0.5;
|
84 | */
|
85 | get type(): OmniOscillatorType;
|
86 | set type(type: OmniOscillatorType);
|
87 | /**
|
88 | * The value is an empty array when the type is not "custom".
|
89 | * This is not available on "pwm" and "pulse" oscillator types.
|
90 | * @see {@link Oscillator.partials}
|
91 | */
|
92 | get partials(): number[];
|
93 | set partials(partials: number[]);
|
94 | get partialCount(): number;
|
95 | set partialCount(partialCount: number);
|
96 | set(props: Partial<OmniOscillatorOptions>): this;
|
97 | /**
|
98 | * connect the oscillator to the frequency and detune signals
|
99 | */
|
100 | private _createNewOscillator;
|
101 | get phase(): Degrees;
|
102 | set phase(phase: Degrees);
|
103 | /**
|
104 | * The source type of the oscillator.
|
105 | * @example
|
106 | * const omniOsc = new Tone.OmniOscillator(440, "fmsquare");
|
107 | * console.log(omniOsc.sourceType); // 'fm'
|
108 | */
|
109 | get sourceType(): OmniOscSourceType;
|
110 | set sourceType(sType: OmniOscSourceType);
|
111 | private _getOscType;
|
112 | /**
|
113 | * The base type of the oscillator.
|
114 | * @see {@link Oscillator.baseType}
|
115 | * @example
|
116 | * const omniOsc = new Tone.OmniOscillator(440, "fmsquare4");
|
117 | * console.log(omniOsc.sourceType, omniOsc.baseType, omniOsc.partialCount);
|
118 | */
|
119 | get baseType(): OscillatorType | "pwm" | "pulse";
|
120 | set baseType(baseType: OscillatorType | "pwm" | "pulse");
|
121 | |
122 |
|
123 |
|
124 |
|
125 | get width(): IsPulseOscillator<OscType, Signal<"audioRange">>;
|
126 | |
127 |
|
128 |
|
129 |
|
130 | get count(): IsFatOscillator<OscType, number>;
|
131 | set count(count: IsFatOscillator<OscType, number>);
|
132 | |
133 |
|
134 |
|
135 |
|
136 | get spread(): IsFatOscillator<OscType, Cents>;
|
137 | set spread(spread: IsFatOscillator<OscType, Cents>);
|
138 | |
139 |
|
140 |
|
141 |
|
142 | get modulationType(): IsAmOrFmOscillator<OscType, ToneOscillatorType>;
|
143 | set modulationType(mType: IsAmOrFmOscillator<OscType, ToneOscillatorType>);
|
144 | |
145 |
|
146 |
|
147 |
|
148 | get modulationIndex(): IsFMOscillator<OscType, Signal<"positive">>;
|
149 | |
150 |
|
151 |
|
152 |
|
153 | get harmonicity(): IsAmOrFmOscillator<OscType, Signal<"positive">>;
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | get modulationFrequency(): IsPWMOscillator<OscType, Signal<"frequency">>;
|
161 | asArray(length?: number): Promise<Float32Array>;
|
162 | dispose(): this;
|
163 | }
|