UNPKG

2.14 kBTypeScriptView Raw
1import { Frequency, NormalRange, Time } from "../../core/type/Units.js";
2import { Envelope, EnvelopeOptions } from "./Envelope.js";
3export interface FrequencyEnvelopeOptions extends EnvelopeOptions {
4 baseFrequency: Frequency;
5 octaves: number;
6 exponent: number;
7}
8/**
9 * FrequencyEnvelope is an {@link Envelope} which ramps between {@link baseFrequency}
10 * and {@link octaves}. It can also have an optional {@link exponent} to adjust the curve
11 * which it ramps.
12 * @example
13 * const oscillator = new Tone.Oscillator().toDestination().start();
14 * const freqEnv = new Tone.FrequencyEnvelope({
15 * attack: 0.2,
16 * baseFrequency: "C2",
17 * octaves: 4
18 * });
19 * freqEnv.connect(oscillator.frequency);
20 * freqEnv.triggerAttack();
21 * @category Component
22 */
23export declare class FrequencyEnvelope extends Envelope {
24 readonly name: string;
25 /**
26 * Private reference to the base frequency as a number
27 */
28 private _baseFrequency;
29 /**
30 * The number of octaves
31 */
32 private _octaves;
33 /**
34 * Internal scaler from 0-1 to the final output range
35 */
36 private _scale;
37 /**
38 * Apply a power curve to the output
39 */
40 private _exponent;
41 /**
42 * @param attack the attack time in seconds
43 * @param decay the decay time in seconds
44 * @param sustain a percentage (0-1) of the full amplitude
45 * @param release the release time in seconds
46 */
47 constructor(attack?: Time, decay?: Time, sustain?: NormalRange, release?: Time);
48 constructor(options?: Partial<FrequencyEnvelopeOptions>);
49 static getDefaults(): FrequencyEnvelopeOptions;
50 /**
51 * The envelope's minimum output value. This is the value which it
52 * starts at.
53 */
54 get baseFrequency(): Frequency;
55 set baseFrequency(min: Frequency);
56 /**
57 * The number of octaves above the baseFrequency that the
58 * envelope will scale to.
59 */
60 get octaves(): number;
61 set octaves(octaves: number);
62 /**
63 * The envelope's exponent value.
64 */
65 get exponent(): number;
66 set exponent(exponent: number);
67 /**
68 * Clean up
69 */
70 dispose(): this;
71}