Skip to content

Instantly share code, notes, and snippets.

@tado
Last active August 29, 2015 14:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tado/ad9e470b5b84f6296b25 to your computer and use it in GitHub Desktop.
Save tado/ad9e470b5b84f6296b25 to your computer and use it in GitHub Desktop.
Realtime FFT Analysis for Processing
// Processing realtime FFT analysis
import processing.sound.*;
AudioIn input;
FFT fft;
int bands=512;
float[] spectrum = new float[bands];
public void setup() {
size(bands, 360);
background(255);
input = new AudioIn(this, 0);
input.play();
fft = new FFT(this);
fft.input(input, bands);
}
public void draw() {
background(255);
fft.analyze(spectrum);
for (int i = 0; i < bands; i++) {
line( i, height, i, height - spectrum[i]*height*5 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment