Last active
August 29, 2015 14:11
-
-
Save tado/ad9e470b5b84f6296b25 to your computer and use it in GitHub Desktop.
Realtime FFT Analysis for Processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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