Skip to content

Instantly share code, notes, and snippets.

@antoinefortin
Created March 27, 2018 20:51
Show Gist options
  • Save antoinefortin/9d7f9720fe4e52f692558d44838e8923 to your computer and use it in GitHub Desktop.
Save antoinefortin/9d7f9720fe4e52f692558d44838e8923 to your computer and use it in GitHub Desktop.
[SoundEq Processing]
import processing.sound.*;
SoundFile song;
FFT fft;
void setup() {
size(514, 360);
song = new SoundFile(this, "ap.mp3");
song.loop();
fft = new FFT(this, 64);
fft.input(song);
}
void draw() {
fft.analyze();
float w = width / (fft.size()/2);
background(255);
for (int i = 0; i < fft.size()/2; i++) {
stroke(0);
float x = i * w;
float h = map(fft.spectrum[i], 0, 1, 0, height * 2);
fill(i*20 % 255);
rect(x+2, height - h - 2, w-2, h);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment