UNPKG

2.83 kBTypeScriptView Raw
1import { Degrees, Frequency, Seconds, Time } from "../../core/type/Units.js";
2import { Signal } from "../../signal/Signal.js";
3import { Source } from "../Source.js";
4import { PWMOscillatorOptions, ToneOscillatorInterface } from "./OscillatorInterface.js";
5export { PWMOscillatorOptions } from "./OscillatorInterface.js";
6/**
7 * PWMOscillator modulates the width of a Tone.PulseOscillator
8 * at the modulationFrequency. This has the effect of continuously
9 * changing the timbre of the oscillator by altering the harmonics
10 * generated.
11 * @example
12 * return Tone.Offline(() => {
13 * const pwm = new Tone.PWMOscillator(60, 0.3).toDestination().start();
14 * }, 0.1, 1);
15 * @category Source
16 */
17export declare class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneOscillatorInterface {
18 readonly name: string;
19 readonly sourceType = "pwm";
20 /**
21 * the pulse oscillator
22 */
23 private _pulse;
24 /**
25 * the modulator
26 */
27 private _modulator;
28 /**
29 * Scale the oscillator so it doesn't go silent
30 * at the extreme values.
31 */
32 private _scale;
33 /**
34 * The frequency control.
35 */
36 readonly frequency: Signal<"frequency">;
37 /**
38 * The detune of the oscillator.
39 */
40 readonly detune: Signal<"cents">;
41 /**
42 * The width modulation rate of the oscillator.
43 * @example
44 * return Tone.Offline(() => {
45 * const osc = new Tone.PWMOscillator(20, 2).toDestination().start();
46 * }, 0.1, 1);
47 */
48 readonly modulationFrequency: Signal<"frequency">;
49 /**
50 * @param {Frequency} frequency The starting frequency of the oscillator.
51 * @param {Frequency} modulationFrequency The modulation frequency of the width of the pulse.
52 */
53 constructor(frequency?: Frequency, modulationFrequency?: Frequency);
54 constructor(options?: Partial<PWMOscillatorOptions>);
55 static getDefaults(): PWMOscillatorOptions;
56 /**
57 * start the oscillator
58 */
59 protected _start(time: Time): void;
60 /**
61 * stop the oscillator
62 */
63 protected _stop(time: Time): void;
64 /**
65 * restart the oscillator
66 */
67 protected _restart(time: Seconds): void;
68 /**
69 * The type of the oscillator. Always returns "pwm".
70 */
71 get type(): "pwm";
72 /**
73 * The baseType of the oscillator. Always returns "pwm".
74 */
75 get baseType(): "pwm";
76 /**
77 * The partials of the waveform. Cannot set partials for this waveform type
78 */
79 get partials(): number[];
80 /**
81 * No partials for this waveform type.
82 */
83 get partialCount(): number;
84 /**
85 * The phase of the oscillator in degrees.
86 */
87 get phase(): Degrees;
88 set phase(phase: Degrees);
89 asArray(length?: number): Promise<Float32Array>;
90 /**
91 * Clean up.
92 */
93 dispose(): this;
94}