xxxxxxxxxx
47
let cam;
let interval = 35;
let mic
function setup() {
createCanvas(640, 480);
cam = createCapture(VIDEO);
pixelDensity(1);
mic = new p5.AudioIn();
mic.start();
rectMode(CENTER)
cam.hide()
}
function draw() {
background(255,0.8);
let vol = mic.getLevel();
interval = round(map(vol,0,0.11,4,30))
//interval = round(map(mouseX,0,width,1,50))
cam.loadPixels();
//loadpixels();
for (let y = 0; y < height; y += interval) {
for (let x = 0; x < width; x += interval) {
let ind = (x + y * width) * 4;
let r = cam.pixels[ind];
let g = cam.pixels[ind + 1];
let b = cam.pixels[ind + 2];
noStroke();
fill(r, g, b);
//rect(x, y, interval, interval);
ellipse(x, y, interval, interval);
}
}
}
function mousePressed(){
//interval = round(map(mouseX,0,width,4,50))
}