open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

OAVp5.mic.state#

variableoav-p5
OAVp5.mic.state

Where the microphone is: 'off', 'asking', 'on', 'denied' or 'unavailable'.

'off': not started, or stopped. 'asking': the browser is waiting for the user's answer. 'on': sound is coming in, and micIsOn is true. 'denied': the permission was refused (by the user, by the computer's settings, or by an iframe without allow="microphone"). 'unavailable': there is no microphone, none the browser can open, or the page is not on https or localhost. When it is not 'on', OAVp5.mic.error has the browser's reason and a card beside the 🎹 says what to press.

Type
String
Range
'off' | 'asking' | 'on' | 'denied' | 'unavailable'

Changes when you start or stop the microphone and when the browser answers. 'off' until something starts it. Reading it never starts it.

Examples

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

function draw() {
  background(OAVp5.mic.state === 'on' ? 20 : color(90, 30, 30));
  fill(255);
  text('microphone: ' + OAVp5.mic.state, 20, 30);
  if (OAVp5.mic.state === 'denied') text('click the lock left of the address and allow it', 20, 60);
}
The background is red until the microphone is on. The state goes "asking", then "on" when you allow it, or "denied" when you refuse. Asks for the microphone

Related

  • micIsOn Whether the microphone is running right now.
  • OAVp5.mic.error Why the microphone did not start, as the browser's error name such as 'NotAllowedError'; null while there is no error.
  • startMic() Turns the microphone on and returns a promise that says whether it worked.
  • mic Who may turn the microphone on: auto (the first read of micLevel and friends), click (only 🎤 or startMic()) or off (nobody).
  • OAVp5.check() Runs the 🩺 check-up: the version, page, browser, microphone, MIDI, sound, drums, recording, wiring and hints, as a card to screenshot and as an object.

p5/oav-p5.js, line 896

↑ Back to top · All names