Meter
class Component ↳ extends MeterBase<MeterOptions<ChannelCount>, ChannelCount>
Meter gets the RMS
of an input signal. It can also get the raw value of the input signal.
Setting normalRange to true will covert the output to a range of
0-1. See an example using a graphical display
here.
const meter = new Tone.Meter(); const mic = new Tone.UserMedia(); mic.open(); // connect mic to the meter mic.connect(meter); // the current level of the mic setInterval(() => console.log(meter.getValue()), 100);
See also: DCMeter.
Constructor
Section titled “Constructor”new Meter(smoothing?: number)Parameters
-
smoothing
numberoptionalThe amount of smoothing applied between frames.
new Meter(options?: Partial<MeterOptions<ChannelCount>>)Parameters
- options
Partial<MeterOptions<ChannelCount>>optional
Properties
Section titled “Properties”normalRange
Section titled “normalRange”normalRange: booleanIf the output should be in decibels or normal range between 0-1. If normalRange is false,
the output range will be the measured decibel value, otherwise the decibel value will be converted to
the range of 0-1
output
Section titled “output”↳ inherited from MeterBase
output: OutputNodeThe output is just a pass through of the input
smoothing
Section titled “smoothing”smoothing: numberA value from between 0 and 1 where 0 represents no time averaging with the last analysis frame.
channels
Section titled “channels”read-only
channels: ChannelCountThe number of channels of analysis.
Methods
Section titled “Methods”getValue()
Section titled “getValue()”getValue(): ChannelCount extends 1 ? number : number[]Get the current value of the incoming signal.
Output is in decibels when normalRange is false.
If channels = 1, then the output is a single number
representing the value of the input signal. When channels > 1,
then each channel is returned as a value in a number array.
Returns ChannelCount extends 1 ? number : number[]
getDefaults()
Section titled “getDefaults()”static
getDefaults(): MeterOptions<1>Returns all of the default options belonging to the class.
Returns MeterOptions<1>
getLevel()
Section titled “getLevel()”getLevel(): number | number[]Use getValue instead. For the previous getValue behavior, use DCMeter.
Returns number | number[]
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()