minim audio question for art istallation
in
Core Library Questions
•
2 years ago
hi to everyone!
I'm a beginner in processing and I need a sketch that simply change background from white to black when microphone detect a sound.
So when microphone detect a sound, processing draw a black rect that have same high and width of canvas.
I think that I've to use minim audio, I found on web this code, but I need something different. Thanks a lot
import ddf.minim.*;
Minim minim;
AudioInput in;
void setup()
{ size(512, 200, P3D);
minim = new Minim(this);
minim.debugOn();
// get a line in from Minim, default bit depth is 16
in = minim.getLineIn(Minim.STEREO, 512); }
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();
}
1