Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

re-added FFT demo

  • Loading branch information...
commit 844aadcb497eb6534daa016bd371c343e17744c3 1 parent a3b4290
Max Henstell authored
Showing with 62 additions and 22 deletions.
  1. +39 −0 FFT.pde
  2. +23 −22 domeTransmitter.pde
View
39 FFT.pde
@@ -0,0 +1,39 @@
+class FFTDemo extends Routine {
+ FFT fft;
+ Minim minim;
+ AudioInput audioin;
+
+ void setup(PApplet parent) {
+ super.setup(parent);
+ minim = new Minim(parent);
+ audioin = minim.getLineIn(Minim.STEREO, 2048);
+ fft = new FFT(audioin.bufferSize(), audioin.sampleRate());
+ }
+
+ void draw() {
+ long frame = frameCount - modeFrameStart;
+
+ background(0);
+ stroke(255);
+
+ fft.forward(audioin.mix);
+
+ for (int i = 0; i < fft.specSize(); i++)
+ {
+ // draw the line for frequency band i, scaling it by 4 so we can see it a bit better
+ // stroke(0,0,255);
+ // line(i, HEIGHT, i, HEIGHT - fft.getBand(i)*4);
+ // //line(i, HEIGHT, i, HEIGHT - fft.getBand(i));
+ float barHeight = fft.getBand(i)*4;
+ for (float c = 0; c < barHeight; c++) {
+ stroke(c/barHeight*255, 0, 255);
+ point(i, HEIGHT - c);
+ }
+ }
+
+ if (frame > FRAMERATE*TYPICAL_MODE_TIME) {
+ newMode();
+ }
+ }
+}
+
View
45 domeTransmitter.pde
@@ -3,6 +3,8 @@ import processing.opengl.*;
import java.lang.reflect.Method;
import hypermedia.net.*;
import java.io.*;
+import ddf.minim.*;
+import ddf.minim.analysis.*;
int WIDTH = 25;
int HEIGHT = 160;
@@ -12,20 +14,20 @@ String hostname = "127.0.0.1"; //"192.168.1.130";
int TYPICAL_MODE_TIME = 30;
Routine[] enabledRoutines = new Routine[] {
- new Greetz(),
- new Bursts(),
- new Flash(),
- new Lines(),
- new OppositeLines(),
- new Waves(),
- new RadialStars(),
- new NightSky(),
- new TargetScanner(),
- new Waterfalls(),
- // new FFT(),
- new RGBRoutine(),
- new FlashColors(),
- new FollowMouse()
+ // new Greetz(),
+ // new Bursts(),
+ // new Flash(),
+ // new Lines(),
+ // new OppositeLines(),
+ // new Waves(),
+ // new RadialStars(),
+ // new NightSky(),
+ // new TargetScanner(),
+ // new Waterfalls(),
+ new FFTDemo(),
+ // new RGBRoutine(),
+ // new FlashColors(),
+ // new FollowMouse()
};
int w = 0;
@@ -48,16 +50,16 @@ int fadeInFrames = 0;
void setup() {
// Had to enable OPENGL for some reason new fonts don't work in JAVA2D.
- size(WIDTH,HEIGHT);
+ size(WIDTH, HEIGHT);
frameRate(FRAMERATE);
-
+
dacwes = new Dacwes(this, WIDTH, HEIGHT);
dacwes.setAddress(hostname);
dacwes.setAddressingMode(Dacwes.ADDRESSING_VERTICAL_NORMAL);
setMode(0);
-
+
for (Routine r : enabledRoutines) {
r.setup(this);
}
@@ -79,7 +81,7 @@ void setMode(int newMode) {
mode = newMode;
modeFrameStart = frameCount;
println("New mode " + currentRoutine.getClass().getName());
-
+
currentRoutine.reset();
}
@@ -96,7 +98,7 @@ void newMode() {
}
setMode(newMode);
-// dacwes.sendMode(enabledModes[newMode]);
+ // dacwes.sendMode(enabledModes[newMode]);
}
void draw() {
@@ -125,8 +127,7 @@ void draw() {
currentRoutine.isDone = false;
newMode();
}
-// println(frameRate);
- dacwes.sendData();
+ // println(frameRate);
+ dacwes.sendData();
}
-
Please sign in to comment.
Something went wrong with that request. Please try again.