open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

OAVp5.mic.rms#

variableoav-p5
OAVp5.mic.rms

The raw loudness of the microphone: a smoothed RMS, 0 to 1, before oav-p5 turns it into the decibel scale of micLevel.

The root mean square of the samples in the latest frame, smoothed a little. It is linear, the way a waveform is drawn, so it suits a quick check or your own scale. micLevel is built from it: OAVp5.mic.db is the same number in dBFS, and OAVp5.mic.floor is the room's own noise, in dBFS too.

Type
Number
Range
0..1

Updated once per display frame while the microphone is on; 0 when it is off. A speaking voice into a laptop is a small number, in the range 0.01 to 0.05 according to the comment in the code, which is why micLevel works in decibels.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  startMic();
}

function draw() {
  background(20);
  fill(255);
  text('rms ' + nf(OAVp5.mic.rms, 1, 4), 20, 30);
  rect(20, 60, min(OAVp5.mic.rms * 10, 1) * (width - 40), 20);   // magnified 10 times: a voice is small
}
The raw RMS as a number and a bar, magnified ten times because speech is a small number. Allow the microphone and talk. Asks for the microphone

To be confirmed

Typical values for speech and music depend on the microphone and the room. The 0.01 to 0.05 for a voice is the code comment's figure and was not measured here.

Related

  • OAVp5.mic.db The loudness of the microphone in decibels relative to full scale (dBFS): 0 is as loud as it gets, −100 is silence or the microphone being off.
  • OAVp5.mic.floor The room's own noise as oav-p5 has measured it, in dBFS: the level that micLevel treats as silence (plus 6 dB).
  • OAVp5.mic.level The same 0 to 1 loudness as micLevel, read without ever turning the microphone on.
  • micLevel How loud the microphone hears things, from 0 (a quiet room) to 1 (shouting).

p5/oav-p5.js, line 900

↑ Back to top · All names