open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

OAVp5.mic.bass#

variableoav-p5
OAVp5.mic.bass

Also: OAVp5.mic.mid OAVp5.mic.treble

The same 0 to 1 low, middle and high energy as bass, mid and treble, read without ever turning the microphone on.

The plain bass, mid and treble ask for the microphone when first read, and a sketch that already has a variable of that name keeps it. OAVp5.mic.bass, .mid and .treble are the numbers themselves: always there, never starting anything. They are also the answer when the plain names are taken: on strudel.cc, where Strudel owns bass, this is what the card tells you to read.

Type
Number
Range
0..1

bass is 20–250 Hz, mid 250–2000 Hz and treble 2000–8000 Hz, scaled by the sensitivity and held to 1. Updated once per display frame while the microphone is on; 0 otherwise.

Notes

  • The three share this entry because they behave the same: only the frequency range differs.

Examples

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

function draw() {
  background(20);
  const bands = [OAVp5.mic.bass, OAVp5.mic.mid, OAVp5.mic.treble];
  for (let i = 0; i < 3; i++) {
    fill(255, 80 + i * 70, 120);
    rect(60 + i * 110, height - 20, 80, -20 - bands[i] * 240);
  }
}
Three bars for low, middle and high, written with the raw members. Whistle for the right one, hum for the left. Asks for the microphone

Related

  • bass How much of the microphone's sound is low (bass), middle (mid) or high (treble), each from 0 to 1.
  • OAVp5.mic.level The same 0 to 1 loudness as micLevel, read without ever turning the microphone on.
  • micSensitivity() Makes the microphone more or less sensitive: micSensitivity(2) is twice as sensitive, micSensitivity() says what it is now.
  • startMic() Turns the microphone on and returns a promise that says whether it worked.

p5/oav-p5.js, line 899

↑ Back to top · All names