Created
February 19, 2016 09:57
-
-
Save gregtemp/167780e981b82d565c52 to your computer and use it in GitHub Desktop.
This file contains 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 processing.serial.*; | |
import ddf.minim.analysis.*; | |
import ddf.minim.*; | |
Minim minim; | |
AudioInput in; | |
FFT fft; | |
Serial myPort; // Create object from Serial class | |
int val; // Data received from the serial port | |
int oldinval; | |
void setup() | |
{ | |
size(255, 255); | |
minim = new Minim(this); | |
in = minim.getLineIn(); | |
fft = new FFT( in.bufferSize(), in.sampleRate() ); | |
String portName = Serial.list()[0]; | |
println(Serial.list()); | |
myPort = new Serial(this, "/dev/cu.usbmodem1411", 9600); | |
println(fft.specSize()); | |
} | |
void draw() { | |
background(255); | |
fft.forward( in.mix ); | |
int bassint = int(fft.getBand(4) * 8); | |
int midint = int(fft.getBand(10) * 20); | |
int himidint = int(fft.getBand(100) * 100); | |
int hiint = int(fft.getBand(300) * 200); | |
byte out[] = new byte[4]; | |
out[0] = byte(bassint); | |
out[1] = byte(midint); | |
out[2] = byte(himidint); | |
out[3] = byte(hiint); | |
myPort.write(out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment