UNPKG

2.34 kBTypeScriptView Raw
1import { NormalRange } from "../../core/type/Units.js";
2import { MeterBase, MeterBaseOptions } from "./MeterBase.js";
3export interface MeterOptions extends MeterBaseOptions {
4 smoothing: NormalRange;
5 normalRange: boolean;
6 channelCount: number;
7}
8/**
9 * Meter gets the [RMS](https://en.wikipedia.org/wiki/Root_mean_square)
10 * of an input signal. It can also get the raw value of the input signal.
11 * Setting `normalRange` to `true` will covert the output to a range of
12 * 0-1. See an example using a graphical display
13 * [here](https://tonejs.github.io/examples/meter).
14 * @see {@link DCMeter}.
15 *
16 * @example
17 * const meter = new Tone.Meter();
18 * const mic = new Tone.UserMedia();
19 * mic.open();
20 * // connect mic to the meter
21 * mic.connect(meter);
22 * // the current level of the mic
23 * setInterval(() => console.log(meter.getValue()), 100);
24 * @category Component
25 */
26export declare class Meter extends MeterBase<MeterOptions> {
27 readonly name: string;
28 /**
29 * If the output should be in decibels or normal range between 0-1. If `normalRange` is false,
30 * the output range will be the measured decibel value, otherwise the decibel value will be converted to
31 * the range of 0-1
32 */
33 normalRange: boolean;
34 /**
35 * A value from between 0 and 1 where 0 represents no time averaging with the last analysis frame.
36 */
37 smoothing: number;
38 /**
39 * The previous frame's value for each channel.
40 */
41 private _rms;
42 /**
43 * @param smoothing The amount of smoothing applied between frames.
44 */
45 constructor(smoothing?: NormalRange);
46 constructor(options?: Partial<MeterOptions>);
47 static getDefaults(): MeterOptions;
48 /**
49 * Use {@link getValue} instead. For the previous getValue behavior, use DCMeter.
50 * @deprecated
51 */
52 getLevel(): number | number[];
53 /**
54 * Get the current value of the incoming signal.
55 * Output is in decibels when {@link normalRange} is `false`.
56 * If {@link channels} = 1, then the output is a single number
57 * representing the value of the input signal. When {@link channels} > 1,
58 * then each channel is returned as a value in a number array.
59 */
60 getValue(): number | number[];
61 /**
62 * The number of channels of analysis.
63 */
64 get channels(): number;
65 dispose(): this;
66}