open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

OAVp5.mic.db#

variableoav-p5
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.

Decibels are what an ear hears: each 6 dB is twice the amplitude, so a number in dB moves the way loudness feels. micLevel maps it onto 0 to 1 between the room's noise floor (+6 dB) and −10 dBFS. Use db directly when you want your own scale, for example map(OAVp5.mic.db, -60, -10, 0, 1).

Type
Number
Range
-100..0

20 * log10(rms), measured from OAVp5.mic.rms. −100 when the level is below about −100 dB and while the microphone is off. Updated once per display frame.

Examples

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

function draw() {
  background(20);
  fill(255);
  text(nf(OAVp5.mic.db, 1, 1) + ' dBFS', 20, 30);
  const own = constrain(map(OAVp5.mic.db, -60, -10, 0, 1), 0, 1);   // an own scale: -60 dB to -10 dB
  circle(width / 2, height / 2, 50 + own * 300);
}
The level in dBFS, and a circle on an own scale from −60 to −10 dB. Allow the microphone and talk. Asks for the microphone

Related

  • 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.
  • 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