xxxxxxxxxx
37
let mic;
function setup() {
createCanvas(600, 400);
// https://p5js.org/reference/#/p5.AudioIn
mic = new p5.AudioIn();
mic.start();
//colorMode(HSB); // hue (0 - 360), sat (0 - 100), brightness (0 - 100)
}
function draw() {
//background(180, 100, 50, 0.4); // h, s, b, a
background(120, 120, 120, 5); // r, g, b, a (0 - 255)
const xCircle = width / 2;
const yCircle = height /2;
// getLevel() returns sound level as decimal 0 - 1
// where 1 is loudest
let micLevel = mic.getLevel();
let diameter = 400 * micLevel;
noStroke();
fill(255, 255, 255);
circle(xCircle, yCircle, diameter); // x, y, diameter
}