UNPKG

2.5 kBTypeScriptView Raw
1import { InputNode, OutputNode, ToneAudioNode, ToneAudioNodeOptions } from "../../core/context/ToneAudioNode.js";
2import { NormalRange, PowerOfTwo } from "../../core/type/Units.js";
3export type AnalyserType = "fft" | "waveform";
4export interface AnalyserOptions extends ToneAudioNodeOptions {
5 size: PowerOfTwo;
6 type: AnalyserType;
7 smoothing: NormalRange;
8 channels: number;
9}
10/**
11 * Wrapper around the native Web Audio's [AnalyserNode](http://webaudio.github.io/web-audio-api/#idl-def-AnalyserNode).
12 * Extracts FFT or Waveform data from the incoming signal.
13 * @category Component
14 */
15export declare class Analyser extends ToneAudioNode<AnalyserOptions> {
16 readonly name: string;
17 readonly input: InputNode;
18 readonly output: OutputNode;
19 /**
20 * The analyser node.
21 */
22 private _analysers;
23 /**
24 * Input and output are a gain node
25 */
26 private _gain;
27 /**
28 * The channel splitter node
29 */
30 private _split;
31 /**
32 * The analysis type
33 */
34 private _type;
35 /**
36 * The buffer that the FFT data is written to
37 */
38 private _buffers;
39 /**
40 * @param type The return type of the analysis, either "fft", or "waveform".
41 * @param size The size of the FFT. This must be a power of two in the range 16 to 16384.
42 */
43 constructor(type?: AnalyserType, size?: number);
44 constructor(options?: Partial<AnalyserOptions>);
45 static getDefaults(): AnalyserOptions;
46 /**
47 * Run the analysis given the current settings. If {@link channels} = 1,
48 * it will return a Float32Array. If {@link channels} > 1, it will
49 * return an array of Float32Arrays where each index in the array
50 * represents the analysis done on a channel.
51 */
52 getValue(): Float32Array | Float32Array[];
53 /**
54 * The size of analysis. This must be a power of two in the range 16 to 16384.
55 */
56 get size(): PowerOfTwo;
57 set size(size: PowerOfTwo);
58 /**
59 * The number of channels the analyser does the analysis on. Channel
60 * separation is done using {@link Split}
61 */
62 get channels(): number;
63 /**
64 * The analysis function returned by analyser.getValue(), either "fft" or "waveform".
65 */
66 get type(): AnalyserType;
67 set type(type: AnalyserType);
68 /**
69 * 0 represents no time averaging with the last analysis frame.
70 */
71 get smoothing(): NormalRange;
72 set smoothing(val: NormalRange);
73 /**
74 * Clean up.
75 */
76 dispose(): this;
77}