Created
March 28, 2017 15:30
-
-
Save jeonghopark/6cf98780c469f9a253e285d94e6d868c to your computer and use it in GitHub Desktop.
Minim Sound FFT Default Setting
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 ddf.minim.analysis.*; | |
| import ddf.minim.*; | |
| Minim minim; | |
| AudioPlayer jingle; | |
| FFT fftLin; | |
| float spectrumScale = 20; | |
| PFont font; | |
| void setup() { | |
| size(512, 480); | |
| minim = new Minim(this); | |
| jingle = minim.loadFile("jingle.mp3", 1024); | |
| jingle.loop(); | |
| fftLin = new FFT( jingle.bufferSize(), jingle.sampleRate() ); | |
| fftLin.linAverages( 10 ); | |
| } | |
| void draw() { | |
| background(0); | |
| fftLin.forward( jingle.mix ); | |
| int w = int( width/fftLin.avgSize() ); | |
| for (int i = 0; i < fftLin.avgSize(); i++) { | |
| fill(255, 0, 0); | |
| rect(i * w, 240, w, -fftLin.getAvg(i) * spectrumScale); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment