Created
March 20, 2018 02:27
-
-
Save AlexLamson/8fe64eff543394ef06083a9f24bc5a32 to your computer and use it in GitHub Desktop.
Realtime FFT from the microphone with the minim processing library
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; | |
AudioSource in; | |
FFT fft; | |
void setup() { | |
size(512, 200); | |
//handle audio input | |
minim = new Minim(this); | |
in = minim.getLineIn(); | |
fft = new FFT( in.bufferSize(), in.sampleRate() ); | |
} | |
void draw() { | |
background(0); | |
stroke(255); | |
// perform a forward FFT on the samples in jingle's mix buffer, | |
// which contains the mix of both the left and right channels of the file | |
fft.forward( in.mix ); | |
for(int i = 0; i < fft.specSize(); i++) { | |
// draw the line for frequency band i, scaling it up a bit so we can see it | |
line( i, height, i, height - fft.getBand(i)*8 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment