OAVp5.mic#
objectoav-p5OAVp5.mic
The microphone under the plain names: its state, the numbers of micLevel and bass that never turn it on when read, the raw loudness, start, stop and events.
Everything the microphone names (micLevel, bass, micIsOn, startMic() …) read from here. The difference is that reading OAVp5.mic.level never asks for the microphone: the plain micLevel does, the first time. So OAVp5.mic is for code that must look without waking anything: a status line, a library, a sketch with ?oav_mic=click.
The members: state, error, sensitivity (also gain), level, bass (also mid, treble), rms, db, floor, analyzer, start(), stop() and on().
Notes
- This is advanced. For most sketches the plain names are all you need.
Examples
function setup() {
createCanvas(400, 300);
}
function mousePressed() {
if (OAVp5.mic.state === 'on') OAVp5.mic.stop(); else OAVp5.mic.start();
}
function draw() {
background(20);
fill(255);
text('microphone: ' + OAVp5.mic.state + ' (click the canvas to switch it)', 20, 30); // reading this asks for nothing
circle(width / 2, height / 2, 50 + OAVp5.mic.level * 300);
}Related
micLevelHow loud the microphone hears things, from 0 (a quiet room) to 1 (shouting).bassHow much of the microphone's sound is low (bass), middle (mid) or high (treble), each from 0 to 1.micIsOnWhether the microphone is running right now.startMic()Turns the microphone on and returns a promise that says whether it worked.stopMic()Turns the microphone off and sets every microphone value back to 0.micWho may turn the microphone on:auto(the first read ofmicLeveland friends),click(only 🎤 orstartMic()) oroff(nobody).