RTCAudioSourceStats: totalAudioEnergy property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The totalAudioEnergy property of the RTCAudioSourceStats dictionary represents the total audio energy of the media source over the lifetime of this stats object.
Note:
For audio energy of remotely sourced tracks, see RTCInboundRtpStreamStats.totalAudioEnergy.
Value
A number.
Description
The totalAudioEnergy value is the sum of the energy of every audio sample (a single measurement of the sound's level) that the media source has produced over the lifetime of this stats object.
To calculate the energy of a sample, divide the sample's value by the highest-intensity encodable value, which is the largest value the audio format can represent.
Then square the result, and multiply it by the duration of the sample in seconds.
In the following equation, sample_level is the value of the sample, max_level is the highest-intensity encodable value, and duration is the length of the sample in seconds:
If the audio has more than one channel, the energy of a sample is the highest energy of any of its channels.
Because the value is a running total, you can find the energy over a particular period by subtracting the values returned by two different getStats() calls.
You can also use it with totalSamplesDuration to calculate the average audio level over the lifetime of the stats object, or between two getStats() calls.
For the formulas, see the RTCAudioSourceStats Description.
Specifications
| Specification |
|---|
| Identifiers for WebRTC's Statistics API> # dom-rtcaudiosourcestats-totalaudioenergy> |