import krister.Ess.*; AudioChannel myChannel; FFT myFFT; int bands = 256; // Number of FFT frequency bands to calculate void setup() { size(1024, 600); Ess.start(this); // Start Ess // Load "girl2.aif" into a new AudioChannel, file must be in the "data" folder myChannel = new AudioChannel("girl2.aif"); myChannel.play(Ess.FOREVER); myFFT = new FFT(bands *2); // We want 256 frequency bands, so we pass in 512 } void draw() { background(0); // Get spectrum myFFT.getSpectrum(myChannel); // Draw FFT data stroke(255); for (int i = 0; i < bands; i++) { float x = width - pow(1024, (255.0 -i) / bands); float maxY = max(0, myFFT.maxSpectrum[i] * height*2); float freY = max(0, myFFT.spectrum[i] * height*2); // Draw maximum lines stroke(30, 144, 255); line(x, height, x, height-maxY); // Draw frequency lines stroke(100); line(x, height, x, height-freY); } } public void stop() { Ess.stop(); // When program stops, stop Ess too super.stop(); }