UNPKG

2.18 kBTypeScriptView Raw
1import { ToneAudioNode, ToneAudioNodeOptions } from "../../core/context/ToneAudioNode.js";
2import { Frequency } from "../../core/type/Units.js";
3import { Gain } from "../../core/context/Gain.js";
4export type OnePoleFilterType = "highpass" | "lowpass";
5export interface OnePoleFilterOptions extends ToneAudioNodeOptions {
6 frequency: Frequency;
7 type: OnePoleFilterType;
8}
9/**
10 * A one pole filter with 6db-per-octave rolloff. Either "highpass" or "lowpass".
11 * Note that changing the type or frequency may result in a discontinuity which
12 * can sound like a click or pop.
13 * References:
14 * * http://www.earlevel.com/main/2012/12/15/a-one-pole-filter/
15 * * http://www.dspguide.com/ch19/2.htm
16 * * https://github.com/vitaliy-bobrov/js-rocks/blob/master/src/app/audio/effects/one-pole-filters.ts
17 * @category Component
18 */
19export declare class OnePoleFilter extends ToneAudioNode<OnePoleFilterOptions> {
20 readonly name: string;
21 /**
22 * Hold the current frequency
23 */
24 private _frequency;
25 /**
26 * the current one pole type
27 */
28 private _type;
29 /**
30 * the current one pole filter
31 */
32 private _filter;
33 readonly input: Gain;
34 readonly output: Gain;
35 /**
36 * @param frequency The frequency
37 * @param type The filter type, either "lowpass" or "highpass"
38 */
39 constructor(frequency?: Frequency, type?: OnePoleFilterType);
40 constructor(options?: Partial<OnePoleFilterOptions>);
41 static getDefaults(): OnePoleFilterOptions;
42 /**
43 * Create a filter and dispose the old one
44 */
45 private _createFilter;
46 /**
47 * The frequency value.
48 */
49 get frequency(): Frequency;
50 set frequency(fq: Frequency);
51 /**
52 * The OnePole Filter type, either "highpass" or "lowpass"
53 */
54 get type(): OnePoleFilterType;
55 set type(t: OnePoleFilterType);
56 /**
57 * Get the frequency response curve. This curve represents how the filter
58 * responses to frequencies between 20hz-20khz.
59 * @param len The number of values to return
60 * @return The frequency response curve between 20-20kHz
61 */
62 getFrequencyResponse(len?: number): Float32Array;
63 dispose(): this;
64}