glitch pixels with sound

edited August 2015 in How To...

Hello everyone!

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.

Any idea? Any Minim thing for mic input?

Thank you all in advance.


  • edited August 2015

    Here is what I've come up with, so far...

    // 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);
    void captureEvent(Capture video) {
      // Read image from the camera;
      size(512, 200, P3D);
      minim = new Minim(this);
      // get a line in from Minim, default bit depth is 16
      in = minim.getLineIn(Minim.STEREO, 512);
    void draw() {
      // 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];
          rect(x, y, videoScale, videoScale);
      // 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
  • _vk_vk
    edited August 2015

    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.

Sign In or Register to comment.