Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (37 sloc) 1.057 kb
844aadcb »
2012-05-17 re-added FFT demo
1 class FFTDemo extends Routine {
2 FFT fft;
3 Minim minim;
4 AudioInput audioin;
5
6 void setup(PApplet parent) {
7 super.setup(parent);
8 minim = new Minim(parent);
9 audioin = minim.getLineIn(Minim.STEREO, 2048);
10 fft = new FFT(audioin.bufferSize(), audioin.sampleRate());
11 }
12
13 void draw() {
14 long frame = frameCount - modeFrameStart;
15
16 background(0);
17 stroke(255);
18
19 fft.forward(audioin.mix);
20
21 for (int i = 0; i < fft.specSize(); i++)
22 {
23 // draw the line for frequency band i, scaling it by 4 so we can see it a bit better
24 // stroke(0,0,255);
25 // line(i, HEIGHT, i, HEIGHT - fft.getBand(i)*4);
26 // //line(i, HEIGHT, i, HEIGHT - fft.getBand(i));
27 float barHeight = fft.getBand(i)*4;
28 for (float c = 0; c < barHeight; c++) {
0a809368 »
2012-05-25 Made comm compatible with Dacwes again
29 if (isRGB) {
30 stroke(c/barHeight*255, 0, 255);
31 }
32 else {
33 stroke(255-(c/barHeight*255));
34 }
844aadcb »
2012-05-17 re-added FFT demo
35 point(i, HEIGHT - c);
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.