xxxxxxxxxx
54
let rec = [];
let angle = 0;
let total = 180;
let end = 5;
let count;
let spectrum;
function setup() {
createCanvas(600, 600, WEBGL);
angleMode(DEGREES);
noFill();
strokeWeight(1);
mic = new p5.AudioIn();
mic.start();
mic.amp(0.1);
fft = new p5.FFT();
fft.setInput(mic);
}
function draw() {
background(220);
spectrum = fft.analyze();
// translate(0, 0, -100);
orbitControl();
// rotateZ(35);
// rotateX(45);
for (let i = 0; i < spectrum.length; i++) {
rec.push(spectrum[i]);
}
count = 3;
for (let i = 0; i < total; i += end) {
beginShape();
for (let j = 0; j < total * 2 + 1; j += end) {
let r = 200;
let x = r * sin(j * count) * cos(i);
let y = r * sin(j) * sin(i);
let z = r * cos(j);
let fv = createVector(x, y, z);
fv.add(count);
vertex(fv.x, fv.y, fv.z);
}
endShape();
}
}