One of my complaints about Flash is that it still can't capture wave forms of sound from sources like the microphone or line-in.
With processing, it's like taking candy from a baby.
Here is a sample to get audio input from your PC and use the sample data to a create visual effect on a video image.
I didn't uploaded the completed applet because it didin't seem to work on a web page(neither does the example on the Minim library's online documentation).
If run on a PC with web-cam and microphone, this example will show an image from the camera distorted according to the waveforms as you talk or sing.
With processing, it's like taking candy from a baby.
Here is a sample to get audio input from your PC and use the sample data to a create visual effect on a video image.
I didn't uploaded the completed applet because it didin't seem to work on a web page(neither does the example on the Minim library's online documentation).
If run on a PC with web-cam and microphone, this example will show an image from the camera distorted according to the waveforms as you talk or sing.
import ddf.minim.*;
import processing.video.*;
Minim minim;
AudioInput in;
Capture cam;
void setup() {
size(320, 240);
cam = new Capture(this, width, height);
minim = new Minim(this);
minim.debugOn();
in = minim.getLineIn(Minim.MONO, 512);
}
void draw() {
drawImage();
}
void drawImage() {
float lev;
PImage img = createImage(width,height,RGB);
int ty;
if (cam.available() == true) {
cam.read();
cam.loadPixels();
for (int i = 0; i < width; i ++) {
lev = in.left.get(int(float(i) / width * 511)) * 60;
for (int j = 0; j <height; j ++) {
ty = int(j + lev);
if (ty < 0) { ty += height; }
if (ty >= height) { ty -= height; }
img.pixels[i + j * width] = cam.pixels[i + ty * width];
}
}
image(img, 0, 0);
}
}
void stop() {
in.close();
minim.stop();
super.stop();
}



Leave a comment