UNPKG

2.08 kBTypeScriptView Raw
1import { Hertz, NormalRange, PowerOfTwo } from "../../core/type/Units.js";
2import { MeterBase, MeterBaseOptions } from "./MeterBase.js";
3export interface FFTOptions extends MeterBaseOptions {
4 size: PowerOfTwo;
5 smoothing: NormalRange;
6 normalRange: boolean;
7}
8/**
9 * Get the current frequency data of the connected audio source using a fast Fourier transform.
10 * Read more about FFT algorithms on [Wikipedia] (https://en.wikipedia.org/wiki/Fast_Fourier_transform).
11 * @category Component
12 */
13export declare class FFT extends MeterBase<FFTOptions> {
14 readonly name: string;
15 /**
16 * If the output should be in decibels or normal range between 0-1. If `normalRange` is false,
17 * the output range will be the measured decibel value, otherwise the decibel value will be converted to
18 * the range of 0-1
19 */
20 normalRange: boolean;
21 /**
22 * @param size The size of the FFT. Value must be a power of two in the range 16 to 16384.
23 */
24 constructor(size?: PowerOfTwo);
25 constructor(options?: Partial<FFTOptions>);
26 static getDefaults(): FFTOptions;
27 /**
28 * Gets the current frequency data from the connected audio source.
29 * Returns the frequency data of length {@link size} as a Float32Array of decibel values.
30 */
31 getValue(): Float32Array;
32 /**
33 * The size of analysis. This must be a power of two in the range 16 to 16384.
34 * Determines the size of the array returned by {@link getValue} (i.e. the number of
35 * frequency bins). Large FFT sizes may be costly to compute.
36 */
37 get size(): PowerOfTwo;
38 set size(size: PowerOfTwo);
39 /**
40 * 0 represents no time averaging with the last analysis frame.
41 */
42 get smoothing(): NormalRange;
43 set smoothing(val: NormalRange);
44 /**
45 * Returns the frequency value in hertz of each of the indices of the FFT's {@link getValue} response.
46 * @example
47 * const fft = new Tone.FFT(32);
48 * console.log([0, 1, 2, 3, 4].map(index => fft.getFrequencyOfIndex(index)));
49 */
50 getFrequencyOfIndex(index: number): Hertz;
51}