xxxxxxxxxx
31
var mic;
let bgcolor;
function setup() {
createCanvas(600, 600);
mic = new p5.AudioIn();
mic.start();
bgcolor = color(250);
}
function draw() {
background(bgcolor);
let vol = mic.getLevel();
if (vol > 0.1) {
bgcolor = color(random(255), random(255), random(255));
}
fill("purple");
ellipse(500, 500, vol * 300, vol * 300);
fill("yellow");
ellipse(400, 400, vol * 300, vol * 300);
fill("blue");
ellipse(300, 300, vol * 300, vol * 300);
fill("red");
ellipse(200, 200, vol * 300, vol * 300);
fill("green");
ellipse(100, 100, vol * 300, vol * 300);
}