Hi Guys, would love it if someone could point me in the right direction here because I’m very stuck. My goal is to use the mic inputs to move the amplitude of the lines across the screen, creating sort of a sound visualisation on top of the camera thing. Been struggling big time with keeping the camera effect whilst trying to implement this, so any help would be greatly appreciated!
This is my code so far
import processing.video.*;
import processing.sound.*;
Capture cam;
AudioIn input;
Amplitude analyzer;
void setup()
{
size(displayWidth, displayHeight);
stroke(255);
strokeWeight(2);
noFill();
smooth(4);
pixelDensity(displayDensity());
input = new AudioIn(this, 0);
input.start();
analyzer = new Amplitude(this);
analyzer.input(input);
String[] cameras = Capture.list();
cam = new Capture(this, displayWidth, displayHeight);
cam.start();
}
void draw() {
background(50);
cam.read();
cam.loadPixels();
float vol = analyzer.analyze();
float loud = vol*200;
println(loud);
for (int y = 0; y < cam.height; y +=11) // replacing the 11 with loud (using volume*50 not volume*200), the whole thing crashes
{
beginShape();
for (int x = 0; x < cam.width; x += 7)
{
int pixel = cam.pixels[x + y*cam.width];
float c = map(blue(pixel), 0, 255, 0, 20); //so far I have replaced the 20 here with loud, which sort of works but isnt really what im looking for.
curveVertex(x, y-c); //replacing x, y or c with loud doesnt work either.
}
endShape();
}
}