xxxxxxxxxx
67
let mic;
let canvas;
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
function setup() {
canvas = createCanvas(windowWidth, windowHeight);
canvas.position(0, 0);
frameRate(10);
//canvas.style('z-index','-1');
mic = new p5.AudioIn();
mic.start();
}
function keyPressed() {
clear();
for(i=0; i<500; i++){
xa=random(windowWidth);
ya=random(15000);
xb=xa-random(-20,20);
yb=ya-random(-20,20);
line(xa,ya,xb,yb);
push();
stroke(255, 128, 128);
circle(xa+random(-100,100),ya+random(-100,100),random(10));
pop();
}
}
function draw() {
background(255);
let vol = mic.getLevel();
let h = map(vol, 0, 0.1, height/2, 0);
let r=map(vol,0,0.5,10,1000);
//ellipse(width / 2, h - 25, 50, 50);
for(i=0; i<10; i++){
xa=random(windowWidth);
ya=random(windowHeight);
xb=xa-random(-20,20);
yb=ya-random(-20,20);
line(xa,ya,xb,yb);
push();
stroke(255, 128, 128);
circle(xa+random(-100,100),ya+random(-100,100),r);
pop();
noLoop();
}
if (mouseIsPressed) {
line(pmouseX, pmouseY, mouseX, mouseY);
}
}