UNPKG

2.65 kBTypeScriptView Raw
1import { Positive, Time } from "../core/type/Units.js";
2import { Source, SourceOptions } from "../source/Source.js";
3export type NoiseType = "white" | "brown" | "pink";
4export interface NoiseOptions extends SourceOptions {
5 type: NoiseType;
6 playbackRate: Positive;
7 fadeIn: Time;
8 fadeOut: Time;
9}
10/**
11 * Noise is a noise generator. It uses looped noise buffers to save on performance.
12 * Noise supports the noise types: "pink", "white", and "brown". Read more about
13 * colors of noise on [Wikipedia](https://en.wikipedia.org/wiki/Colors_of_noise).
14 *
15 * @example
16 * // initialize the noise and start
17 * const noise = new Tone.Noise("pink").start();
18 * // make an autofilter to shape the noise
19 * const autoFilter = new Tone.AutoFilter({
20 * frequency: "8n",
21 * baseFrequency: 200,
22 * octaves: 8
23 * }).toDestination().start();
24 * // connect the noise
25 * noise.connect(autoFilter);
26 * // start the autofilter LFO
27 * autoFilter.start();
28 * @category Source
29 */
30export declare class Noise extends Source<NoiseOptions> {
31 readonly name: string;
32 /**
33 * Private reference to the source
34 */
35 private _source;
36 /**
37 * private reference to the type
38 */
39 private _type;
40 /**
41 * The playback rate of the noise. Affects
42 * the "frequency" of the noise.
43 */
44 private _playbackRate;
45 /**
46 * The fadeIn time of the amplitude envelope.
47 */
48 protected _fadeIn: Time;
49 /**
50 * The fadeOut time of the amplitude envelope.
51 */
52 protected _fadeOut: Time;
53 /**
54 * @param type the noise type (white|pink|brown)
55 */
56 constructor(type?: NoiseType);
57 constructor(options?: Partial<NoiseOptions>);
58 static getDefaults(): NoiseOptions;
59 /**
60 * The type of the noise. Can be "white", "brown", or "pink".
61 * @example
62 * const noise = new Tone.Noise().toDestination().start();
63 * noise.type = "brown";
64 */
65 get type(): NoiseType;
66 set type(type: NoiseType);
67 /**
68 * The playback rate of the noise. Affects
69 * the "frequency" of the noise.
70 */
71 get playbackRate(): Positive;
72 set playbackRate(rate: Positive);
73 /**
74 * internal start method
75 */
76 protected _start(time?: Time): void;
77 /**
78 * internal stop method
79 */
80 protected _stop(time?: Time): void;
81 /**
82 * The fadeIn time of the amplitude envelope.
83 */
84 get fadeIn(): Time;
85 set fadeIn(time: Time);
86 /**
87 * The fadeOut time of the amplitude envelope.
88 */
89 get fadeOut(): Time;
90 set fadeOut(time: Time);
91 protected _restart(time?: Time): void;
92 /**
93 * Clean up.
94 */
95 dispose(): this;
96}