1 | import { Degrees, Frequency, Seconds } from "../../core/type/Units.js";
|
2 | import { Signal } from "../../signal/Signal.js";
|
3 | import { Source } from "../Source.js";
|
4 | import { AMConstructorOptions, AMOscillatorOptions, ToneOscillatorInterface, ToneOscillatorType } from "./OscillatorInterface.js";
|
5 | export { AMOscillatorOptions } from "./OscillatorInterface.js";
|
6 | /**
|
7 | * An amplitude modulated oscillator node. It is implemented with
|
8 | * two oscillators, one which modulators the other's amplitude
|
9 | * through a gain node.
|
10 | * ```
|
11 | * +-------------+ +----------+
|
12 | * | Carrier Osc +>------> GainNode |
|
13 | * +-------------+ | +--->Output
|
14 | * +---> gain |
|
15 | * +---------------+ | +----------+
|
16 | * | Modulator Osc +>---+
|
17 | * +---------------+
|
18 | * ```
|
19 | * @example
|
20 | * return Tone.Offline(() => {
|
21 | * const amOsc = new Tone.AMOscillator(30, "sine", "square").toDestination().start();
|
22 | * }, 0.2, 1);
|
23 | * @category Source
|
24 | */
|
25 | export declare class AMOscillator extends Source<AMOscillatorOptions> implements ToneOscillatorInterface {
|
26 | readonly name: string;
|
27 | /**
|
28 | * The carrier oscillator
|
29 | */
|
30 | private _carrier;
|
31 | readonly frequency: Signal<"frequency">;
|
32 | readonly detune: Signal<"cents">;
|
33 | /**
|
34 | * The modulating oscillator
|
35 | */
|
36 | private _modulator;
|
37 | /**
|
38 | * convert the -1,1 output to 0,1
|
39 | */
|
40 | private _modulationScale;
|
41 | /**
|
42 | * Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
|
43 | * A harmonicity of 1 gives both oscillators the same frequency.
|
44 | * Harmonicity = 2 means a change of an octave.
|
45 | * @example
|
46 | * const amOsc = new Tone.AMOscillator("D2").toDestination().start();
|
47 | * Tone.Transport.scheduleRepeat(time => {
|
48 | * amOsc.harmonicity.setValueAtTime(1, time);
|
49 | * amOsc.harmonicity.setValueAtTime(0.5, time + 0.5);
|
50 | * amOsc.harmonicity.setValueAtTime(1.5, time + 1);
|
51 | * amOsc.harmonicity.setValueAtTime(1, time + 2);
|
52 | * amOsc.harmonicity.linearRampToValueAtTime(2, time + 4);
|
53 | * }, 4);
|
54 | * Tone.Transport.start();
|
55 | */
|
56 | readonly harmonicity: Signal<"positive">;
|
57 | /**
|
58 | * the node where the modulation happens
|
59 | */
|
60 | private _modulationNode;
|
61 | /**
|
62 | * @param frequency The starting frequency of the oscillator.
|
63 | * @param type The type of the carrier oscillator.
|
64 | * @param modulationType The type of the modulator oscillator.
|
65 | */
|
66 | constructor(frequency?: Frequency, type?: ToneOscillatorType, modulationType?: ToneOscillatorType);
|
67 | constructor(options?: Partial<AMConstructorOptions>);
|
68 | static getDefaults(): AMOscillatorOptions;
|
69 | /**
|
70 | * start the oscillator
|
71 | */
|
72 | protected _start(time: Seconds): void;
|
73 | /**
|
74 | * stop the oscillator
|
75 | */
|
76 | protected _stop(time: Seconds): void;
|
77 | protected _restart(time: Seconds): void;
|
78 | /**
|
79 | * The type of the carrier oscillator
|
80 | */
|
81 | get type(): ToneOscillatorType;
|
82 | set type(type: ToneOscillatorType);
|
83 | get baseType(): OscillatorType;
|
84 | set baseType(baseType: OscillatorType);
|
85 | get partialCount(): number;
|
86 | set partialCount(partialCount: number);
|
87 | /**
|
88 | * The type of the modulator oscillator
|
89 | */
|
90 | get modulationType(): ToneOscillatorType;
|
91 | set modulationType(type: ToneOscillatorType);
|
92 | get phase(): Degrees;
|
93 | set phase(phase: Degrees);
|
94 | get partials(): number[];
|
95 | set partials(partials: number[]);
|
96 | asArray(length?: number): Promise<Float32Array>;
|
97 | /**
|
98 | * Clean up.
|
99 | */
|
100 | dispose(): this;
|
101 | }
|