open-audiovisual
Search GitHub

oav-p5 reference · Microphone and audio analysis

OAVp5.mic.stop()#

functionoav-p5
OAVp5.mic.stop()

Turns the microphone off and sets every microphone value back to 0: the same as stopMic().

stopMic() is this function. It stops the microphone's tracks and closes its audio context, so the browser's "recording" indicator goes away, and OAVp5.mic.level, bass, mid, treble, rms read 0 and db reads −100. After it, only OAVp5.mic.start() or 🎤 turns the microphone back on: reading micLevel does not.

Returns

Promise<Boolean> Resolves to false, the new state of the microphone.

Examples

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

function mousePressed() {
  OAVp5.mic.stop();   // the browser's recording indicator goes away
}

function draw() {
  background(20);
  fill(255);
  text('microphone: ' + OAVp5.mic.state + ' (click the canvas to stop it)', 20, 30);
  circle(width / 2, height / 2, 50 + OAVp5.mic.level * 300);
}
Click the canvas: the microphone stops, the state says "off" and the circle drops to its smallest size. Asks for the microphone

Related

  • stopMic() Turns the microphone off and sets every microphone value back to 0.
  • OAVp5.mic.start() Turns the microphone on and returns a promise that says whether it worked: the same as startMic().
  • OAVp5.mic.state Where the microphone is: 'off', 'asking', 'on', 'denied' or 'unavailable'.
  • micIsOn Whether the microphone is running right now.

p5/oav-p5.js, line 901

↑ Back to top · All names