let mic;
function nx(x) {
return lerp(0, width, x);
}
function ny(y) {
return lerp(0, height, y);
}
function setup() {
BG = “#25233a”
FG = “#ffffff”
SG = “#ff22aa”
createCanvas(windowWidth, windowHeight);
mic = new p5.AudioIn();
mic.start();
mw = 20;
mh = 20;
tw = norm(0.5, 0, mw);
th = norm(0.5, 0, mh);
}
function draw() {
background(BG);
let vol = mic.getLevel();
stroke(FG)
strokeWeight(1);
for (let y = 0; y < mw; y++) {
for (let x = 0; x
< mh; x++) {
ax = nx(norm(x, 0, mw)+tw);
ay = ny(norm(y, 0, mh)+th);
push();
translate(ax, ay);
n = noise(frameCount*0.01)*(x-mh/2)*(y-mh/2)*0.1;
l = nx(vol*n);
rotate(n*10);
line(0, 0, l, 0);
pop();
}
}
}