xxxxxxxxxx
51
let cam;
let mic;
let interval = 4;
function setup() {
createCanvas(640, 480);
cam = createCapture(VIDEO);
cam.hide();
mic = new p5.AudioIn()
mic.start();
}
function draw() {
background(220);
let vol = mic.getLevel();
interval = round(map(vol,0,1, 25,2))
cam.loadPixels();
for(let x =0 ; x<width; x+=interval){
for(let y = 0; y <height ; y+=interval){
let i = (x + y*width) *4;
let r= cam.pixels[i];
let g = cam.pixels[i +1];
let b = cam.pixels[i+2];
fill(r,g,b);
rect(x,y, interval, interval);
}
}
console.log(interval)
// image(cam, 0, 0);
// fill(255,0,0,100);
// ellipse(mouseX,mouseY, 1050,1050)
}