Skip to content

Instantly share code, notes, and snippets.

@jaegonlee
Created September 10, 2018 07:18
Show Gist options
  • Save jaegonlee/7575a0c3ceaa6eb8064b3bb5915a6f6f to your computer and use it in GitHub Desktop.
Save jaegonlee/7575a0c3ceaa6eb8064b3bb5915a6f6f to your computer and use it in GitHub Desktop.
processing audio frequency analyze
import processing.sound.*;
AudioIn input;
FFT fft;
//float smoothingFactor = 0.2;
float[] sum = new float[128];
public void setup() {
size(512, 360);
background(255);
input = new AudioIn(this, 0);
input.start();
fft = new FFT(this, 128);
fft.input(input);
}
public void draw() {
background(125, 255, 125);
fill(255, 0, 150);
noStroke();
fft.analyze();
for (int i = 0; i < 128; i++) {
//sum[i] += (fft.spectrum[i] - sum[i]) * smoothingFactor;
sum[i] = fft.spectrum[i];
rect(i*4, height, 4, -sum[i]*height);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment