Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Advice on how to convert sound into camera distortion?

$
0
0

I'm working on a program that distorts camera feed using audio input and I was just wondering if people had advice on libraries/concepts/necessary to do this? Or if they'd be willing to share their experience with past programming projects?

here's what I've gotten to so far:

/*
Be Careful with your speaker volume, you might produce a painful
feedback. We recommend to wear headphones for this example.

*/

import processing.sound.*;
import processing.video.*;

AudioIn input;
Amplitude rms;
Capture cam;

int scale=1;

void setup() {
    size(1200,800);
    background(255);

    //Create an Audio input and grab the 1st channel
    input = new AudioIn(this, 0);

    // start the Audio Input
    input.start();

    // create a new Amplitude analyzer
    rms = new Amplitude(this);

    // Patch the input to an volume analyzer
    rms.input(input);
  String[] cameras = Capture.list();

  if (cameras == null) {
    println("Failed to retrieve the list of available cameras, will try the default...");
    cam = new Capture(this, 640, 480);
  } if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    printArray(cameras);

    cam = new Capture(this, cameras[0]);

    cam.start();

    background(0,0,0);
      noStroke();
  }
}



void draw() {

    input.amp(map(mouseY, 0, height, 0.0, 200.0));

    scale=int(map(rms.analyze(), 0, 0.5, 1, 350));
    noStroke();

      if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0, width, height);

 }

Viewing all articles
Browse latest Browse all 2896

Trending Articles