Skip to content

Instantly share code, notes, and snippets.

@awhitty
Created May 19, 2013 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awhitty/5606184 to your computer and use it in GitHub Desktop.
Save awhitty/5606184 to your computer and use it in GitHub Desktop.
import ddf.minim.*;
Minim minim;
AudioInput in;
int counter;
void setup()
{
size(1024, 768, P2D);
minim = new Minim(this);
// get a line in from Minim, default bit depth is 16
in = minim.getLineIn(Minim.STEREO, 1024);
background(0);
counter = 0;
}
void draw()
{
stroke(0);
noFill();
stroke(255,50);
// draw the waveforms
beginShape();
for(int i = 0; i < in.bufferSize() - 1; i++)
{
curveVertex(i, (counter*2) + in.left.get(i)*100);
}
endShape();
counter++;
}
void keyPressed() {
// clear the screen and reset the frame count when the user presses the b key.
if (key == 'b' || key == 'B') {
background(0);
counter = 0;
}
}
void stop()
{
in.close();
minim.stop();
super.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment