Knowledge Base
totalAudioEnergy
The audio energy of the receiving track.
Description
Real number; in dBov
MUST NOT exist for video (this is audio only).
Represents the audio energy of the receiving track. For audio energy of tracks attached locally, see RTCAudioSourceStats instead.
This value MUST be computed as follows: for each audio sample that is received (and thus counted by totalSamplesReceived), add the sample's value divided by the highest-intensity encodable value, squared and then multiplied by the duration of the sample in seconds. In other words, duration * Math.pow(energy/maxEnergy, 2).
This can be used to obtain a root mean square (RMS) value that uses the same units as audioLevel, as defined in RFC6464. It can be converted to these units using the formula Math.sqrt(totalAudioEnergy/totalSamplesDuration). This calculation can also be performed using the differences between the values of two different getStats() calls, in order to compute the average audio level over any desired time interval. In other words, do Math.sqrt((energy2 - energy1)/(duration2 - duration1)).
For example, if a 10ms packet of audio is produced with an RMS of 0.5 (out of 1.0), this should add 0.5 * 0.5 * 0.01 = 0.0025 to totalAudioEnergy. If another 10ms packet with an RMS of 0.1 is received, this should similarly add 0.0001 to totalAudioEnergy. Then, Math.sqrt(totalAudioEnergy/totalSamplesDuration) becomes Math.sqrt(0.0026/0.02) = 0.36, which is the same value that would be obtained by doing an RMS calculation over the contiguous 20ms segment of audio.
If multiple audio channels are used, the audio energy of a sample refers to the highest energy of any channel.
See also
- inbound-rtp->audioLevel
- inbound-rtp->totalSamplesReceived
- inbound-rtp->totalSamplesduration
- WebRTC Statistics Specification

Notes
- An audio sample refers to having a sample in any channel of an audio track - if multiple audio channels are used, metrics based on samples do not increment at a higher rate, simultaneously having samples in multiple channels counts as a single sample