Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Making dots bigger recognizing volume or pitch of the voice (mic)

$
0
0

I have used the mirror2 code (in video->capture)

and I want these dots(ellipses) to change color by using the pitch of the voice, also

if the volume of the voice is very big then, the dots will become bigger too, and the other way around

(if the voice pitch is high the dots' color becomes bright colors, and if the voice pitch is low, dark colors)

It is possible to make this code?

Please help me.

 

 

Mirror2 code

 

/**
 * Mirror 2
 * by Daniel Shiffman.
 *
 * Each pixel from the video source is drawn as a rectangle with size based on brightness. 
 */
 
import processing.video.*;

// Size of each cell in the grid
int cellSize = 10;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;


void setup() {
  size(640, 480, P2D);
  // Set up columns and rows
  cols = width / cellSize;
  rows = height / cellSize;
  colorMode(RGB, 255, 255, 255, 100);
  ellipseMode(CENTER);

  // Uses the default video input, see the reference if this causes an error
  video = new Capture(this, width, height);
  video.start();

  background(0);
}


void draw() {
  if (video.available()) {
    video.read();
    video.loadPixels();
   
    background(0, 0, 255);

    // 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 * cellSize;
        int y = j * cellSize;
        int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror the image

        // Each rect is colored white with a size determined by brightness
        color c = video.pixels[loc];
        float sz = (brightness(c) / 255.0) * cellSize;
        fill(255);
        noStroke();
        ellipse(x + cellSize/2, y + cellSize/2, sz, sz);
      }
    }
  }
}


Viewing all articles
Browse latest Browse all 1768

Trending Articles