UNPKG

2.36 kBTypeScriptView Raw
1import { AmplitudeEnvelope } from "../component/envelope/AmplitudeEnvelope.js";
2import { NormalRange, Time } from "../core/type/Units.js";
3import { RecursivePartial } from "../core/util/Interface.js";
4import { Noise, NoiseOptions } from "../source/Noise.js";
5import { Instrument, InstrumentOptions } from "./Instrument.js";
6import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
7import { EnvelopeOptions } from "../component/envelope/Envelope.js";
8export interface NoiseSynthOptions extends InstrumentOptions {
9 envelope: Omit<EnvelopeOptions, keyof ToneAudioNodeOptions>;
10 noise: Omit<NoiseOptions, keyof ToneAudioNodeOptions>;
11}
12/**
13 * Tone.NoiseSynth is composed of {@link Noise} through an {@link AmplitudeEnvelope}.
14 * ```
15 * +-------+ +-------------------+
16 * | Noise +>--> AmplitudeEnvelope +>--> Output
17 * +-------+ +-------------------+
18 * ```
19 * @example
20 * const noiseSynth = new Tone.NoiseSynth().toDestination();
21 * noiseSynth.triggerAttackRelease("8n", 0.05);
22 * @category Instrument
23 */
24export declare class NoiseSynth extends Instrument<NoiseSynthOptions> {
25 readonly name = "NoiseSynth";
26 /**
27 * The noise source.
28 */
29 readonly noise: Noise;
30 /**
31 * The amplitude envelope.
32 */
33 readonly envelope: AmplitudeEnvelope;
34 constructor(options?: RecursivePartial<NoiseSynthOptions>);
35 static getDefaults(): NoiseSynthOptions;
36 /**
37 * Start the attack portion of the envelopes. Unlike other
38 * instruments, Tone.NoiseSynth doesn't have a note.
39 * @example
40 * const noiseSynth = new Tone.NoiseSynth().toDestination();
41 * noiseSynth.triggerAttack();
42 */
43 triggerAttack(time?: Time, velocity?: NormalRange): this;
44 /**
45 * Start the release portion of the envelopes.
46 */
47 triggerRelease(time?: Time): this;
48 sync(): this;
49 /**
50 * Trigger the attack and then the release after the duration.
51 * @param duration The amount of time to hold the note for
52 * @param time The time the note should start
53 * @param velocity The volume of the note (0-1)
54 * @example
55 * const noiseSynth = new Tone.NoiseSynth().toDestination();
56 * // hold the note for 0.5 seconds
57 * noiseSynth.triggerAttackRelease(0.5);
58 */
59 triggerAttackRelease(duration: Time, time?: Time, velocity?: NormalRange): this;
60 dispose(): this;
61}