Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (36 sloc) 1.099 kb
1e26fce @cibomahto Use displayHeight and displayWidth instead of HEIGHT and WIDTH, so we ca...
cibomahto authored
1 import ddf.minim.*;
2 import ddf.minim.signals.*;
3 import ddf.minim.analysis.*;
4 import ddf.minim.effects.*;
5
844aadc re-added FFT demo
Max Henstell authored
6 class FFTDemo extends Routine {
7 FFT fft;
8 Minim minim;
9 AudioInput audioin;
10
11 void setup(PApplet parent) {
12 super.setup(parent);
13 minim = new Minim(parent);
14 audioin = minim.getLineIn(Minim.STEREO, 2048);
15 fft = new FFT(audioin.bufferSize(), audioin.sampleRate());
16 }
17
18 void draw() {
19 long frame = frameCount - modeFrameStart;
20
21 background(0);
22 stroke(255);
23
24 fft.forward(audioin.mix);
25
26 for (int i = 0; i < fft.specSize(); i++)
27 {
28 // draw the line for frequency band i, scaling it by 4 so we can see it a bit better
29 // stroke(0,0,255);
1e26fce @cibomahto Use displayHeight and displayWidth instead of HEIGHT and WIDTH, so we ca...
cibomahto authored
30 // line(i, displayHeight, i, displayHeight - fft.getBand(i)*4);
31 // //line(i, displayHeight, i, displayHeight - fft.getBand(i));
844aadc re-added FFT demo
Max Henstell authored
32 float barHeight = fft.getBand(i)*4;
33 for (float c = 0; c < barHeight; c++) {
34 stroke(c/barHeight*255, 0, 255);
1e26fce @cibomahto Use displayHeight and displayWidth instead of HEIGHT and WIDTH, so we ca...
cibomahto authored
35 point(i, displayHeight - c);
844aadc re-added FFT demo
Max Henstell authored
36 }
37 }
38
39 if (frame > FRAMERATE*TYPICAL_MODE_TIME) {
40 newMode();
41 }
42 }
43 }
44
Something went wrong with that request. Please try again.