1 | import { Degrees, Frequency, Seconds, Time } from "../../core/type/Units.js";
|
2 | import { Signal } from "../../signal/Signal.js";
|
3 | import { Source } from "../Source.js";
|
4 | import { FMConstructorOptions, FMOscillatorOptions, ToneOscillatorInterface, ToneOscillatorType } from "./OscillatorInterface.js";
|
5 | export { FMOscillatorOptions } from "./OscillatorInterface.js";
|
6 | /**
|
7 | * FMOscillator implements a frequency modulation synthesis
|
8 | * ```
|
9 | * +-------------+
|
10 | * +---------------+ +-------------+ | Carrier Osc |
|
11 | * | Modulator Osc +>-------> GainNode | | +--->Output
|
12 | * +---------------+ | +>----> frequency |
|
13 | * +--> gain | +-------------+
|
14 | * | +-------------+
|
15 | * +-----------------+ |
|
16 | * | modulationIndex +>--+
|
17 | * +-----------------+
|
18 | * ```
|
19 | *
|
20 | * @example
|
21 | * return Tone.Offline(() => {
|
22 | * const fmOsc = new Tone.FMOscillator({
|
23 | * frequency: 200,
|
24 | * type: "square",
|
25 | * modulationType: "triangle",
|
26 | * harmonicity: 0.2,
|
27 | * modulationIndex: 3
|
28 | * }).toDestination().start();
|
29 | * }, 0.1, 1);
|
30 | * @category Source
|
31 | */
|
32 | export declare class FMOscillator extends Source<FMOscillatorOptions> implements ToneOscillatorInterface {
|
33 | readonly name: string;
|
34 | /**
|
35 | * The carrier oscillator
|
36 | */
|
37 | private _carrier;
|
38 | readonly frequency: Signal<"frequency">;
|
39 | readonly detune: Signal<"cents">;
|
40 | /**
|
41 | * The modulating oscillator
|
42 | */
|
43 | private _modulator;
|
44 | /**
|
45 | * Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
|
46 | * A harmonicity of 1 gives both oscillators the same frequency.
|
47 | * Harmonicity = 2 means a change of an octave.
|
48 | * @example
|
49 | * const fmOsc = new Tone.FMOscillator("D2").toDestination().start();
|
50 | * // pitch the modulator an octave below carrier
|
51 | * fmOsc.harmonicity.value = 0.5;
|
52 | */
|
53 | readonly harmonicity: Signal<"positive">;
|
54 | /**
|
55 | * The modulation index which is in essence the depth or amount of the modulation. In other terms it is the
|
56 | * ratio of the frequency of the modulating signal (mf) to the amplitude of the
|
57 | * modulating signal (ma) -- as in ma/mf.
|
58 | */
|
59 | readonly modulationIndex: Signal<"positive">;
|
60 | /**
|
61 | * the node where the modulation happens
|
62 | */
|
63 | private _modulationNode;
|
64 | /**
|
65 | * @param frequency The starting frequency of the oscillator.
|
66 | * @param type The type of the carrier oscillator.
|
67 | * @param modulationType The type of the modulator oscillator.
|
68 | */
|
69 | constructor(frequency?: Frequency, type?: ToneOscillatorType, modulationType?: ToneOscillatorType);
|
70 | constructor(options?: Partial<FMConstructorOptions>);
|
71 | static getDefaults(): FMOscillatorOptions;
|
72 | /**
|
73 | * start the oscillator
|
74 | */
|
75 | protected _start(time: Time): void;
|
76 | /**
|
77 | * stop the oscillator
|
78 | */
|
79 | protected _stop(time: Time): void;
|
80 | protected _restart(time: Seconds): this;
|
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 | }
|