### 27.2.16 Loudness estimation

The rms command computes the RMS (root mean square) of the audio data (see Section 20.2.1 for other uses of rms).

- rms command takes one mandatory argument and two optional arguments:
  - A, an audio clip.
  - Optionally, offset, a nonnegative integer (by default, offset=0).
  - Optionally, len, a positive integer (by default, len=L−offset, where L is the length of A).
- rms(A ⟨,offset,len ⟩) computes RMS for each channel (optionally restricted to the portion of length len starting at offset) and returns the result as √∑cRMSc2, where RMSc is the RMS of channel c.
- rms operates with sample values mapped to [−1,1], hence the result is in [0,1]. To convert the result to decibels, use the formula RMSdB=20log10(RMS).
- RMS is a measure of the average loudness of the audio.

#### Example

With the file CantinaBand3.wav downloaded from here:

clip:=normalize(readwav("/home/luka/Downloads/CantinaBand3.wav"),0)

a sound clip with 66150 samples at 22050 Hz (16 bit, mono) |  |  |  |  |  |  |  |  |  |

r:=rms(clip)

0.152788493422 |  |  |  |  |  |  |  |  |  |

Average loudness in dB:

20*log10(r)

−16.3181870293 |  |  |  |  |  |  |  |  |  |