Created
March 27, 2018 20:51
-
-
Save antoinefortin/9d7f9720fe4e52f692558d44838e8923 to your computer and use it in GitHub Desktop.
[SoundEq 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
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