new Meter(channels, smoothing, clipMemory)
get the rms of the input signal with some averaging
can also just get the value of the signal
or the value in dB
inspired by https://github.com/cwilso/volume-meter/blob/master/volume-meter.js
The MIT License (MIT) Copyright (c) 2014 Chris Wilson
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
channels |
number |
<optional> |
(optional) number of channels being metered |
smoothing |
number |
<optional> |
(optional) amount of smoothing applied to the volume |
clipMemory |
number |
<optional> |
(optional) number in ms that a "clip" should be remembered |
Extends
Members
-
<private> _jsNode :ScriptProcessorNode
-
Type:
- ScriptProcessorNode
-
<private> _lastClip :number
-
last time the values clipped
Type:
- number
-
<private> _values :Array.<number>
-
the raw values for each of the channels
Type:
- Array.<number>
-
<private> _volume :Array.<number>
-
the rms for each of the channels
Type:
- Array.<number>
-
channels :number
-
Type:
- number
-
clipMemory :number
-
Type:
- number
-
isFrequency
-
true if the input is in the format number+hz i.e.: 10hz
- Inherited From:
- Source:
-
isNotation
-
tests if a string is musical notation i.e.: 4n = quarter note 2m = two measures 8t = eighth-note triplet
- Inherited From:
- Source:
-
isTransportTime
-
tests if a string is transportTime i.e. : 1:2:0 = 1 measure + two quarter notes + 0 sixteenth notes
- Inherited From:
- Source:
-
smoothing :number
-
Type:
- number
Methods
-
<private> _onprocess(event)
-
called on each processing frame
Parameters:
Name Type Description event
AudioProcessingEvent -
getDb(channel) → {number}
-
get the volume of the signal in dB
Parameters:
Name Type Argument Description channel
number <optional>
Returns:
- Type
- number
-
getLevel(channel) → {number}
-
get the rms of the signal
Parameters:
Name Type Argument Description channel
number <optional>
which channel Returns:
the value- Type
- number
-
getValue(channel) → {number}
-
get the value of the signal
Parameters:
Name Type Argument Description channel
number <optional>
Returns:
- Type
- number
-
notationToSeconds(notation, bpm, timeSignature) → {number}
-
convert notation format strings to seconds
Parameters:
Name Type Argument Description notation
string bpm
number <optional>
timeSignature
number <optional>
- Inherited From:
- Source:
Returns:
- Type
- number
-
receive(channelName)
-
recieve the input from the desired channelName to the input gain of 'this' node.
Parameters:
Name Type Description channelName
string - Inherited From:
- Source:
-
send(channelName, amount) → {GainNode}
-
send signal to a channel name
Parameters:
Name Type Description channelName
string amount
number Returns:
- Type
- GainNode
-
toFrequency(time) → {number}
-
convert a time to a frequency
Parameters:
Name Type Description time
Tone.Time - Inherited From:
- Source:
Returns:
the time in hertz- Type
- number
-
toSeconds(time, bpm, timeSignature)
-
convert Tone.Time into seconds unlike the method which it overrides, this takes into account transporttime and musical notation
Parameters:
Name Type Argument Description time
Tone.Time bpm
number <optional>
timeSignature
number <optional>
- Inherited From:
- Source:
-
toTransportTime(seconds, bpm, timeSignature) → {string}
-
Convert seconds to the closest transportTime in the form measures:quarters:sixteenths
Parameters:
Name Type Argument Description seconds
Tone.Time bpm
number <optional>
timeSignature
number <optional>
- Inherited From:
- Source:
Returns:
- Type
- string
-
transportTimeToSeconds(transportTime, bpm, timeSignature) → {number}
-
convert transportTime into seconds i.e.: 4:2:3 == 4 measures + 2 quarters + 3 sixteenths
Parameters:
Name Type Argument Description transportTime
string bpm
number <optional>
timeSignature
number <optional>
- Inherited From:
- Source:
Returns:
seconds- Type
- number