Created
September 10, 2018 07:18
-
-
Save jaegonlee/7575a0c3ceaa6eb8064b3bb5915a6f6f to your computer and use it in GitHub Desktop.
processing audio frequency analyze
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.*; | |
| 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