UNPKG

2.87 kBTypeScriptView Raw
1import { AmplitudeEnvelope } from "../component/envelope/AmplitudeEnvelope.js";
2import { EnvelopeOptions } from "../component/envelope/Envelope.js";
3import { Filter, FilterOptions } from "../component/filter/Filter.js";
4import { RecursivePartial } from "../core/util/Interface.js";
5import { Monophonic, MonophonicOptions } from "../instrument/Monophonic.js";
6import { OmniOscillator } from "../source/oscillator/OmniOscillator.js";
7import { FrequencyEnvelope, FrequencyEnvelopeOptions } from "../component/envelope/FrequencyEnvelope.js";
8import { NormalRange, Seconds, Time } from "../core/type/Units.js";
9import { Signal } from "../signal/Signal.js";
10import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
11import { OmniOscillatorSynthOptions } from "../source/oscillator/OscillatorInterface.js";
12export interface MonoSynthOptions extends MonophonicOptions {
13 oscillator: OmniOscillatorSynthOptions;
14 envelope: Omit<EnvelopeOptions, keyof ToneAudioNodeOptions>;
15 filterEnvelope: Omit<FrequencyEnvelopeOptions, keyof ToneAudioNodeOptions>;
16 filter: Omit<FilterOptions, keyof ToneAudioNodeOptions>;
17}
18/**
19 * MonoSynth is composed of one `oscillator`, one `filter`, and two `envelopes`.
20 * The amplitude of the Oscillator and the cutoff frequency of the
21 * Filter are controlled by Envelopes.
22 * <img src="https://docs.google.com/drawings/d/1gaY1DF9_Hzkodqf8JI1Cg2VZfwSElpFQfI94IQwad38/pub?w=924&h=240">
23 * @example
24 * const synth = new Tone.MonoSynth({
25 * oscillator: {
26 * type: "square"
27 * },
28 * envelope: {
29 * attack: 0.1
30 * }
31 * }).toDestination();
32 * synth.triggerAttackRelease("C4", "8n");
33 * @category Instrument
34 */
35export declare class MonoSynth extends Monophonic<MonoSynthOptions> {
36 readonly name = "MonoSynth";
37 /**
38 * The oscillator.
39 */
40 readonly oscillator: OmniOscillator<any>;
41 /**
42 * The frequency control.
43 */
44 readonly frequency: Signal<"frequency">;
45 /**
46 * The detune control.
47 */
48 readonly detune: Signal<"cents">;
49 /**
50 * The filter.
51 */
52 readonly filter: Filter;
53 /**
54 * The filter envelope.
55 */
56 readonly filterEnvelope: FrequencyEnvelope;
57 /**
58 * The amplitude envelope.
59 */
60 readonly envelope: AmplitudeEnvelope;
61 constructor(options?: RecursivePartial<MonoSynthOptions>);
62 static getDefaults(): MonoSynthOptions;
63 /**
64 * start the attack portion of the envelope
65 * @param time the time the attack should start
66 * @param velocity the velocity of the note (0-1)
67 */
68 protected _triggerEnvelopeAttack(time: Seconds, velocity?: number): void;
69 /**
70 * start the release portion of the envelope
71 * @param time the time the release should start
72 */
73 protected _triggerEnvelopeRelease(time: Seconds): void;
74 getLevelAtTime(time: Time): NormalRange;
75 dispose(): this;
76}