inspiring visualisations

Resource:

example sketches:

minimal code

//Note: this code requires not only the p5.js library but the p5.js sound library, too.

let fft;

function setup() {
  createCanvas(windowWidth, windowHeight);
	
	//boilerplate audio analysis setup
	let mic = new p5.AudioIn();
  mic.start();  
	fft = new p5.FFT();
  fft.setInput(mic);
}

function draw(){
  background(0, 10);
	fft.analyze(); // Compute the energy levels for each frequency band.
	const energy = fft.getEnergy("treble");
	circle(300, 300, energy * 2);
}

some great dynamic music for visualisation

common errors

cheat sheet

//setup:
let mic = new p5.AudioIn();
mic.start();
fft = new p5.FFT();
fft.setInput(mic);
//per frame, e.g. in p5.js draw() function:
fft.analyze();
// for each frequency of interest
  const level = fft.getEnergy(freq);
  //do something with level (colour / size)