xxxxxxxxxx
23
let mic;
let fft; // fft is = dividing sound into 1024 frequencies
function setup() {
createCanvas(1024, 400);
mic = new p5.AudioIn();
mic.start();
fft = new p5.FFT();
fft.setInput(mic);
}
function draw() {
background(225);
// let level = mic.getLevel();
// if(level > 0.1) background(random(255));
// ellipse(width/2,height/2, level *300, level * 100);
let bins = fft.analyze();
for(let b= 0; b < bins.length; b++) {
let bin = bins[b];
line(b,height-bin,b,height);
}
}