Skip to content

Instantly share code, notes, and snippets.

@timpulver
Created July 12, 2012 18:06
Show Gist options
  • Save timpulver/3099772 to your computer and use it in GitHub Desktop.
Save timpulver/3099772 to your computer and use it in GitHub Desktop.
[P5, Minim] Using live line out signal
/*
* make sure, you have activated stereomix as your recording device in your system settings!
*/
import ddf.minim.*;
import ddf.minim.signals.*;
Minim minim;
AudioInput in;
SineWave sine;
void setup()
{
size(512, 200, P2D);
minim = new Minim(this);
// get a line out from Minim, default sample rate is 44100, default bit depth is 16
in = minim.getLineIn(Minim.STEREO);
}
void draw()
{
background(0);
stroke(255);
// draw the waveforms
for(int i = 0; i < in.bufferSize() - 1; i++)
{
line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
}
}
void stop()
{
// always close Minim audio classes when you are done with them
in.close();
minim.stop();
super.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment