xxxxxxxxxx
// Ideas:
// - Beat detection
// - size/ colour changing on pitch/ loudness/ frequency
// - multiple circles
// - Y movement on pitch
let fft;
function setup() {
createCanvas(windowWidth, windowHeight);
let mic = new p5.AudioIn();
mic.start();
fft = new p5.FFT();
fft.setInput(mic);
}
function draw(){
background(0, 10);
fft.analyze(); //Analyse the audio input
/* getEnergy() accepts:
- Frequency (in Hz)
- "bass", "lowMid", "mid", "highMid", "treble"
Returns a range between 0 (no volume) and 255 (maximum volume).*/
noStroke()
const bassEnergy = fft.getEnergy("bass");
circle(200, 750, bassEnergy * 4); //
const midEnergy = fft.getEnergy("mid");
circle(400, 500, midEnergy * 4);
const trebleEnergy = fft.getEnergy("treble");
circle(600, 300, trebleEnergy * 4);
}