Unable to get full resoultion

edited March 2014 in Using Processing

I'm unable to get the full resolution for following code

import ddf.minim.*;
import ddf.minim.analysis.*;
import processing.video.*;

// Size of each cell in the grid, ratio of window size to video size
int videoScale = 50;
// Number of columns and rows in our system
int cols, rows;
// Variable to hold onto Capture object
Capture video;
Minim minim;
AudioInput in;
FFT fft;
int highest=0;

void setup()
{
  size(1920, 1080);
  // Initialize columns and rows
  cols = width/videoScale;
  rows = height/videoScale;
  video = new Capture(this,width,height);
  video.start();
smooth ();
  minim = new Minim(this);
  minim.debugOn();

  in = minim.getLineIn(Minim.MONO, 4096, 44100);
  fft = new FFT(in.left.size(), 44100);
}

void draw()
{
// Read image from the camera
  if (video.available()) {
    video.read();
  }
  video.loadPixels();

    // Audio gathering here
     fft.forward(in.left);
  highest=0;
  for (int n = 0; n < fft.specSize(); n++) {
    // draw the line for frequency band n, scaling it by 4 so we can see it a bit better
    //line(n/4, height, n/4, height - fft.getBand(n)*4);
    println(fft.getBand(n));
    //find frequency with highest amplitude
    if (fft.getBand(n)>fft.getBand(highest))
      highest=n;
  }


  videoScale = int (-0.185 * highest + 31.6);
  cols = width/videoScale;
  rows = height/videoScale;

 // println(highest,videoScale);

  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[x + y*video.width];
      smooth();
      fill(c);
      stroke(0);
      rect(x,y,videoScale,videoScale);
    }
  }

/*
background(0);
  stroke(255);
  fft.forward(in.left);
  highest=0;
  for (int n = 0; n < fft.specSize(); n++) {
    // draw the line for frequency band n, scaling it by 4 so we can see it a bit better
    line(n/4, height, n/4, height - fft.getBand(n)*4);

    //find frequency with highest amplitude
    if (fft.getBand(n)>fft.getBand(highest))
      highest=n;
  }
  println(highest);

  //println(fft.getFreq(110));
  // 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();
}

Answers

  • Format the code properly, it's difficult to read. Leave one blanks row before you, and press CTRL+K or the C button in the editing menu.

    To go full screen with the frame use size(displayWidth, displayHeight);. To go full screen without the frame comment size() and add this to the bottom:

     boolean sketchFullScreen() {
          return true;
     }
    
  • The reason you cannot go full screen is that your camera doesn't support it unless you have an HD camera. The cols and rows take the value of the screen and not the value of the camera and therefore you will get an error. Also that example is outdated. There is a nice pixelation camera here openprocessing.org/sketch/131816

Sign In or Register to comment.