UNPKG

2.36 kBTypeScriptView Raw
1import { AmplitudeEnvelope } from "../component/envelope/AmplitudeEnvelope.js";
2import { EnvelopeOptions } from "../component/envelope/Envelope.js";
3import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
4import { NormalRange, Seconds, Time } from "../core/type/Units.js";
5import { RecursivePartial } from "../core/util/Interface.js";
6import { Signal } from "../signal/Signal.js";
7import { OmniOscillator } from "../source/oscillator/OmniOscillator.js";
8import { OmniOscillatorSynthOptions } from "../source/oscillator/OscillatorInterface.js";
9import { Monophonic, MonophonicOptions } from "./Monophonic.js";
10export interface SynthOptions extends MonophonicOptions {
11 oscillator: OmniOscillatorSynthOptions;
12 envelope: Omit<EnvelopeOptions, keyof ToneAudioNodeOptions>;
13}
14/**
15 * Synth is composed simply of a {@link OmniOscillator} routed through an {@link AmplitudeEnvelope}.
16 * ```
17 * +----------------+ +-------------------+
18 * | OmniOscillator +>--> AmplitudeEnvelope +>--> Output
19 * +----------------+ +-------------------+
20 * ```
21 * @example
22 * const synth = new Tone.Synth().toDestination();
23 * synth.triggerAttackRelease("C4", "8n");
24 * @category Instrument
25 */
26export declare class Synth<Options extends SynthOptions = SynthOptions> extends Monophonic<Options> {
27 readonly name: string;
28 /**
29 * The oscillator.
30 */
31 readonly oscillator: OmniOscillator<any>;
32 /**
33 * The frequency signal
34 */
35 readonly frequency: Signal<"frequency">;
36 /**
37 * The detune signal
38 */
39 readonly detune: Signal<"cents">;
40 /**
41 * The envelope
42 */
43 readonly envelope: AmplitudeEnvelope;
44 /**
45 * @param options the options available for the synth.
46 */
47 constructor(options?: RecursivePartial<SynthOptions>);
48 static getDefaults(): SynthOptions;
49 /**
50 * start the attack portion of the envelope
51 * @param time the time the attack should start
52 * @param velocity the velocity of the note (0-1)
53 */
54 protected _triggerEnvelopeAttack(time: Seconds, velocity: number): void;
55 /**
56 * start the release portion of the envelope
57 * @param time the time the release should start
58 */
59 protected _triggerEnvelopeRelease(time: Seconds): void;
60 getLevelAtTime(time: Time): NormalRange;
61 /**
62 * clean up
63 */
64 dispose(): this;
65}