UNPKG

3.49 kBTypeScriptView Raw
1import { Envelope, EnvelopeOptions } from "../component/envelope/Envelope.js";
2import { ToneAudioNodeOptions } from "../core/context/ToneAudioNode.js";
3import { Frequency, NormalRange, Positive, Seconds, Time } from "../core/type/Units.js";
4import { RecursivePartial } from "../core/util/Interface.js";
5import { Signal } from "../signal/Signal.js";
6import { Monophonic, MonophonicOptions } from "./Monophonic.js";
7export interface MetalSynthOptions extends MonophonicOptions {
8 harmonicity: Positive;
9 modulationIndex: Positive;
10 octaves: number;
11 resonance: Frequency;
12 envelope: Omit<EnvelopeOptions, keyof ToneAudioNodeOptions>;
13}
14/**
15 * A highly inharmonic and spectrally complex source with a highpass filter
16 * and amplitude envelope which is good for making metallophone sounds.
17 * Based on CymbalSynth by [@polyrhythmatic](https://github.com/polyrhythmatic).
18 * @category Instrument
19 */
20export declare class MetalSynth extends Monophonic<MetalSynthOptions> {
21 readonly name: string;
22 /**
23 * The frequency of the cymbal
24 */
25 readonly frequency: Signal<"frequency">;
26 /**
27 * The detune applied to the oscillators
28 */
29 readonly detune: Signal<"cents">;
30 /**
31 * The array of FMOscillators
32 */
33 private _oscillators;
34 /**
35 * The frequency multipliers
36 */
37 private _freqMultipliers;
38 /**
39 * The gain node for the envelope.
40 */
41 private _amplitude;
42 /**
43 * Highpass the output
44 */
45 private _highpass;
46 /**
47 * The number of octaves the highpass
48 * filter frequency ramps
49 */
50 private _octaves;
51 /**
52 * Scale the body envelope for the highpass filter
53 */
54 private _filterFreqScaler;
55 /**
56 * The envelope which is connected both to the
57 * amplitude and a highpass filter's cutoff frequency.
58 * The lower-limit of the filter is controlled by the {@link resonance}
59 */
60 readonly envelope: Envelope;
61 constructor(options?: RecursivePartial<MetalSynthOptions>);
62 static getDefaults(): MetalSynthOptions;
63 /**
64 * Trigger the attack.
65 * @param time When the attack should be triggered.
66 * @param velocity The velocity that the envelope should be triggered at.
67 */
68 protected _triggerEnvelopeAttack(time: Seconds, velocity?: NormalRange): this;
69 /**
70 * Trigger the release of the envelope.
71 * @param time When the release should be triggered.
72 */
73 protected _triggerEnvelopeRelease(time: Seconds): this;
74 getLevelAtTime(time: Time): NormalRange;
75 /**
76 * The modulationIndex of the oscillators which make up the source.
77 * see {@link FMOscillator.modulationIndex}
78 * @min 1
79 * @max 100
80 */
81 get modulationIndex(): number;
82 set modulationIndex(val: number);
83 /**
84 * The harmonicity of the oscillators which make up the source.
85 * see Tone.FMOscillator.harmonicity
86 * @min 0.1
87 * @max 10
88 */
89 get harmonicity(): number;
90 set harmonicity(val: number);
91 /**
92 * The lower level of the highpass filter which is attached to the envelope.
93 * This value should be between [0, 7000]
94 * @min 0
95 * @max 7000
96 */
97 get resonance(): Frequency;
98 set resonance(val: Frequency);
99 /**
100 * The number of octaves above the "resonance" frequency
101 * that the filter ramps during the attack/decay envelope
102 * @min 0
103 * @max 8
104 */
105 get octaves(): number;
106 set octaves(val: number);
107 dispose(): this;
108}