I am desperately trying to find out how to properly merge Shiffman's video pixelation sketch with some Minim to make rects react to mic input and glitch.
import processing.video.*;
// Size of each cell in the grid, ratio of window size to video size
int videoScale = 8;
// Number of columns and rows in our system
int cols, rows;
// Variable to hold onto Capture object
Capture video;
import ddf.minim.*;
Minim minim;
AudioInput in;
void setup() {
size(640, 480);
// Initialize columns and rows
cols = width / videoScale;
rows = height / videoScale;
video = new Capture(this, 80, 60);
video.start();
}
void captureEvent(Capture video) {
// Read image from the camera
video.read();
}
{
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() {
video.loadPixels();
// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {
// Where are we, pixel-wise?
int x = i * videoScale;
int y = j * videoScale;
// Looking up the appropriate color in the pixel array
color c = video.pixels[i + j * video.width];
fill(c);
stroke(0);
rect(x, y, videoScale, videoScale);
}
{
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();
}
Hello. this code above did not compile. It has some strange blocks(not wrong but strange like lines 58-63) and perhaps a duplicated setup() method without the setup word. lines 30-38...
What you want can be break in:
1 displaying incoming video via a grid of properly coloured rects .
2 making those rects react to sound..
For the 1 you can look at Mirror example that comes with processing (Libraries/video).
Answers
Here is what I've come up with, so far...
Hello. this code above did not compile. It has some strange blocks(not wrong but strange like lines 58-63) and perhaps a duplicated setup() method without the setup word. lines 30-38...
What you want can be break in:
1 displaying incoming video via a grid of properly coloured rects .
2 making those rects react to sound..
For the 1 you can look at Mirror example that comes with processing (Libraries/video).
For 2 MonitorInput example (Libraries/Minim)
Than slowly adapt it and mix both in one sketch.
Come back with issues if needed.