Skip to content

Instantly share code, notes, and snippets.

@moyashipan
Created March 8, 2012 11:09
Show Gist options
  • Save moyashipan/2000483 to your computer and use it in GitHub Desktop.
Save moyashipan/2000483 to your computer and use it in GitHub Desktop.
Processing: Input audio and draw colorilze wave
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