UNPKG

2.88 kBTypeScriptView Raw
1import { Signal } from "../signal/Signal.js";
2import { Multiply } from "../signal/Multiply.js";
3import { Gain } from "../core/context/Gain.js";
4import { NormalRange, Positive, Seconds, Time } from "../core/type/Units.js";
5import { EnvelopeOptions } from "../component/envelope/Envelope.js";
6import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
7import { Monophonic } from "./Monophonic.js";
8import { OmniOscillator } from "../source/oscillator/OmniOscillator.js";
9import { OmniOscillatorSynthOptions } from "../source/oscillator/OscillatorInterface.js";
10import { Synth, SynthOptions } from "./Synth.js";
11import { AmplitudeEnvelope } from "../component/envelope/AmplitudeEnvelope.js";
12import { RecursivePartial } from "../core/util/Interface.js";
13export interface ModulationSynthOptions extends SynthOptions {
14 harmonicity: Positive;
15 modulationEnvelope: Omit<EnvelopeOptions, keyof ToneAudioNodeOptions>;
16 modulation: OmniOscillatorSynthOptions;
17}
18/**
19 * Base class for both AM and FM synths
20 */
21export declare abstract class ModulationSynth<Options extends ModulationSynthOptions> extends Monophonic<Options> {
22 readonly name: string;
23 /**
24 * The carrier voice.
25 */
26 protected _carrier: Synth;
27 /**
28 * The modulator voice.
29 */
30 protected _modulator: Synth;
31 /**
32 * The carrier's oscillator
33 */
34 readonly oscillator: OmniOscillator<any>;
35 /**
36 * The carrier's envelope
37 */
38 readonly envelope: AmplitudeEnvelope;
39 /**
40 * The modulator's oscillator which is applied to the amplitude of the oscillator
41 */
42 readonly modulation: OmniOscillator<any>;
43 /**
44 * The modulator's envelope
45 */
46 readonly modulationEnvelope: AmplitudeEnvelope;
47 /**
48 * The frequency control
49 */
50 readonly frequency: Signal<"frequency">;
51 /**
52 * The detune in cents
53 */
54 readonly detune: Signal<"cents">;
55 /**
56 * Harmonicity is the ratio between the two voices. A harmonicity of
57 * 1 is no change. Harmonicity = 2 means a change of an octave.
58 * @example
59 * const amSynth = new Tone.AMSynth().toDestination();
60 * // pitch the modulator an octave below oscillator
61 * amSynth.harmonicity.value = 0.5;
62 * amSynth.triggerAttackRelease("C5", "4n");
63 */
64 readonly harmonicity: Multiply;
65 /**
66 * The node where the modulation happens
67 */
68 protected _modulationNode: Gain;
69 constructor(options?: RecursivePartial<ModulationSynthOptions>);
70 static getDefaults(): ModulationSynthOptions;
71 /**
72 * Trigger the attack portion of the note
73 */
74 protected _triggerEnvelopeAttack(time: Seconds, velocity: number): void;
75 /**
76 * Trigger the release portion of the note
77 */
78 protected _triggerEnvelopeRelease(time: Seconds): this;
79 getLevelAtTime(time: Time): NormalRange;
80 dispose(): this;
81}