1 | import { AudioRange, Degrees, Frequency, Time } from "../../core/type/Units.js";
|
2 | import { Signal } from "../../signal/Signal.js";
|
3 | import { Source } from "../Source.js";
|
4 | import { ToneOscillatorConstructorOptions, ToneOscillatorInterface, ToneOscillatorOptions, ToneOscillatorType } from "./OscillatorInterface.js";
|
5 | export { ToneOscillatorOptions, ToneOscillatorType, } from "./OscillatorInterface.js";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export declare class Oscillator extends Source<ToneOscillatorOptions> implements ToneOscillatorInterface {
|
17 | readonly name: string;
|
18 | |
19 |
|
20 |
|
21 | private _oscillator;
|
22 | |
23 |
|
24 |
|
25 | frequency: Signal<"frequency">;
|
26 | |
27 |
|
28 |
|
29 | detune: Signal<"cents">;
|
30 | |
31 |
|
32 |
|
33 | private _wave?;
|
34 | |
35 |
|
36 |
|
37 | private _partials;
|
38 | |
39 |
|
40 |
|
41 | private _partialCount;
|
42 | |
43 |
|
44 |
|
45 | private _phase;
|
46 | |
47 |
|
48 |
|
49 | private _type;
|
50 | |
51 |
|
52 |
|
53 |
|
54 | constructor(frequency?: Frequency, type?: ToneOscillatorType);
|
55 | constructor(options?: Partial<ToneOscillatorConstructorOptions>);
|
56 | static getDefaults(): ToneOscillatorOptions;
|
57 | /**
|
58 | * start the oscillator
|
59 | */
|
60 | protected _start(time?: Time): void;
|
61 | /**
|
62 | * stop the oscillator
|
63 | */
|
64 | protected _stop(time?: Time): void;
|
65 | /**
|
66 | * Restart the oscillator. Does not stop the oscillator, but instead
|
67 | * just cancels any scheduled 'stop' from being invoked.
|
68 | */
|
69 | protected _restart(time?: Time): this;
|
70 | /**
|
71 | * Sync the signal to the Transport's bpm. Any changes to the transports bpm,
|
72 | * will also affect the oscillators frequency.
|
73 | * @example
|
74 | * const osc = new Tone.Oscillator().toDestination().start();
|
75 | * osc.frequency.value = 440;
|
76 | * // the ratio between the bpm and the frequency will be maintained
|
77 | * osc.syncFrequency();
|
78 | * // double the tempo
|
79 | * Tone.Transport.bpm.value *= 2;
|
80 | * // the frequency of the oscillator is doubled to 880
|
81 | */
|
82 | syncFrequency(): this;
|
83 | /**
|
84 | * Unsync the oscillator's frequency from the Transport.
|
85 | * @see {@link syncFrequency}
|
86 | */
|
87 | unsyncFrequency(): this;
|
88 | /**
|
89 | * Cache the periodic waves to avoid having to redo computations
|
90 | */
|
91 | private static _periodicWaveCache;
|
92 | /**
|
93 | * Get a cached periodic wave. Avoids having to recompute
|
94 | * the oscillator values when they have already been computed
|
95 | * with the same values.
|
96 | */
|
97 | private _getCachedPeriodicWave;
|
98 | get type(): ToneOscillatorType;
|
99 | set type(type: ToneOscillatorType);
|
100 | get baseType(): OscillatorType;
|
101 | set baseType(baseType: OscillatorType);
|
102 | get partialCount(): number;
|
103 | set partialCount(p: number);
|
104 | /**
|
105 | * Returns the real and imaginary components based
|
106 | * on the oscillator type.
|
107 | * @returns [real: Float32Array, imaginary: Float32Array]
|
108 | */
|
109 | private _getRealImaginary;
|
110 | /**
|
111 | * Compute the inverse FFT for a given phase.
|
112 | */
|
113 | private _inverseFFT;
|
114 | /**
|
115 | * Returns the initial value of the oscillator when stopped.
|
116 | * E.g. a "sine" oscillator with phase = 90 would return an initial value of -1.
|
117 | */
|
118 | getInitialValue(): AudioRange;
|
119 | get partials(): number[];
|
120 | set partials(partials: number[]);
|
121 | get phase(): Degrees;
|
122 | set phase(phase: Degrees);
|
123 | asArray(length?: number): Promise<Float32Array>;
|
124 | dispose(): this;
|
125 | }
|