Created
March 8, 2012 11:09
-
-
Save moyashipan/2000483 to your computer and use it in GitHub Desktop.
Processing: Input audio and draw colorilze wave
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 ddf.minim.*; | |
Minim minim; | |
AudioInput in; | |
float data; | |
int[] col = new int[8]; | |
float angle = 0.0; | |
float offsetAngle = PI / 3; | |
void setup(){ | |
size(512,400); | |
minim = new Minim(this); | |
minim.debugOn(); | |
in = minim.getLineIn(Minim.MONO, 512); | |
frameRate(60); | |
} | |
void draw(){ | |
background(0,0,0); | |
int len = in.bufferSize(); | |
int w = 1; | |
int rCol = 128 + round(sin(angle) * 128); | |
int gCol = 128 + round(sin(angle + offsetAngle) * 128); | |
int bCol = 128 + round(sin(angle + offsetAngle * 2) * 128); | |
for(int i = 0; i < len; i++) | |
{ | |
data = in.mix.get(i); | |
float h = data * 200; | |
stroke(rCol, gCol, bCol); | |
line(i, 200, i, 200 + h); | |
} | |
angle += 0.05; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment