1.9 kBTypeScriptView Raw
1import { Param } from "../../core/context/Param.js";
2import { Cents, Frequency, Seconds, Time } from "../../core/type/Units.js";
3import { OneShotSource, OneShotSourceOptions } from "../OneShotSource.js";
4export interface ToneOscillatorNodeOptions extends OneShotSourceOptions {
5 frequency: Frequency;
6 detune: Cents;
7 type: OscillatorType;
8}
9/**
10 * Wrapper around the native fire-and-forget OscillatorNode.
11 * Adds the ability to reschedule the stop method.
12 * ***{@link Oscillator} is better for most use-cases***
13 * @category Source
14 */
15export declare class ToneOscillatorNode extends OneShotSource<ToneOscillatorNodeOptions> {
16 readonly name: string;
17 /**
18 * The oscillator
19 */
20 private _oscillator;
21 protected _internalChannels: OscillatorNode[];
22 /**
23 * The frequency of the oscillator
24 */
25 readonly frequency: Param<"frequency">;
26 /**
27 * The detune of the oscillator
28 */
29 readonly detune: Param<"cents">;
30 /**
31 * @param frequency The frequency value
32 * @param type The basic oscillator type
33 */
34 constructor(frequency: Frequency, type: OscillatorType);
35 constructor(options?: Partial<ToneOscillatorNodeOptions>);
36 static getDefaults(): ToneOscillatorNodeOptions;
37 /**
38 * Start the oscillator node at the given time
39 * @param time When to start the oscillator
40 */
41 start(time?: Time): this;
42 protected _stopSource(time?: Seconds): void;
43 /**
44 * Sets an arbitrary custom periodic waveform given a PeriodicWave.
45 * @param periodicWave PeriodicWave should be created with context.createPeriodicWave
46 */
47 setPeriodicWave(periodicWave: PeriodicWave): this;
48 /**
49 * The oscillator type. Either 'sine', 'sawtooth', 'square', or 'triangle'
50 */
51 get type(): OscillatorType;
52 set type(type: OscillatorType);
53 /**
54 * Clean up.
55 */
56 dispose(): this;
57}