UNPKG

2.81 kBTypeScriptView Raw
1import { Gain } from "../../core/context/Gain.js";
2import { ToneAudioNode } from "../../core/context/ToneAudioNode.js";
3import { Frequency } from "../../core/type/Units.js";
4import { Signal } from "../../signal/Signal.js";
5import { BiquadFilterOptions } from "./BiquadFilter.js";
6export type FilterRollOff = -12 | -24 | -48 | -96;
7export type FilterOptions = BiquadFilterOptions & {
8 rolloff: FilterRollOff;
9};
10/**
11 * Tone.Filter is a filter which allows for all of the same native methods
12 * as the [BiquadFilterNode](http://webaudio.github.io/web-audio-api/#the-biquadfilternode-interface).
13 * Tone.Filter has the added ability to set the filter rolloff at -12
14 * (default), -24 and -48.
15 * @example
16 * const filter = new Tone.Filter(1500, "highpass").toDestination();
17 * filter.frequency.rampTo(20000, 10);
18 * const noise = new Tone.Noise().connect(filter).start();
19 * @category Component
20 */
21export declare class Filter extends ToneAudioNode<FilterOptions> {
22 readonly name: string;
23 readonly input: Gain<"gain">;
24 readonly output: Gain<"gain">;
25 private _filters;
26 /**
27 * the rolloff value of the filter
28 */
29 private _rolloff;
30 private _type;
31 /**
32 * The Q or Quality of the filter
33 */
34 readonly Q: Signal<"positive">;
35 /**
36 * The cutoff frequency of the filter.
37 */
38 readonly frequency: Signal<"frequency">;
39 /**
40 * The detune parameter
41 */
42 readonly detune: Signal<"cents">;
43 /**
44 * The gain of the filter, only used in certain filter types
45 */
46 readonly gain: Signal<"decibels">;
47 /**
48 * @param frequency The cutoff frequency of the filter.
49 * @param type The type of filter.
50 * @param rolloff The drop in decibels per octave after the cutoff frequency
51 */
52 constructor(frequency?: Frequency, type?: BiquadFilterType, rolloff?: FilterRollOff);
53 constructor(options?: Partial<FilterOptions>);
54 static getDefaults(): FilterOptions;
55 /**
56 * The type of the filter. Types: "lowpass", "highpass",
57 * "bandpass", "lowshelf", "highshelf", "notch", "allpass", or "peaking".
58 */
59 get type(): BiquadFilterType;
60 set type(type: BiquadFilterType);
61 /**
62 * The rolloff of the filter which is the drop in db
63 * per octave. Implemented internally by cascading filters.
64 * Only accepts the values -12, -24, -48 and -96.
65 */
66 get rolloff(): FilterRollOff;
67 set rolloff(rolloff: FilterRollOff);
68 /**
69 * Get the frequency response curve. This curve represents how the filter
70 * responses to frequencies between 20hz-20khz.
71 * @param len The number of values to return
72 * @return The frequency response curve between 20-20kHz
73 */
74 getFrequencyResponse(len?: number): Float32Array;
75 /**
76 * Clean up.
77 */
78 dispose(): this;
79}