Hello, I am kind of new to Processing. What I am trying to do is to make this generative visual react to sound. For now the visual is reacting to the mouse movements, but I would like it to take input from the sound captured by the microphone and generate the visuals. The code for now is this. I guess I will have to use the minim library and the fft audio analyzer but I don't really know how to integrate it to this sketch. Thank you in advance for any help
float[] x;
float[] y;
color[] col;
float s = 0.001;
float depth = 0.5;
PImage img;
void setup() {
size(1000, 1000);
background(255);
int n = 1000;
x = new float[n];
y = new float[n];
col = new color[n];
img = loadImage("imageName0.jpg");
img.resize(width, height);
img.loadPixels();
for (int i = 0; i < x.length; i++) {
x[i]= random(0, width);
y[i]= random(0, height);
int loc = int(x[i]) + int(y[i])*width;
col[i] = img.pixels[loc];
}
}
void draw() {
noStroke();
depth = map(mouseY, 0, height, 0.5, 1.5);
//fill(255, 4); //Uncomment if you don't want to use an image;
for (int i = 0; i < x.length; i++) {
float alpha = customNoise(x[i] * s, y[i] * s)*2*PI;
x[i]+= depth * cos(alpha); // + random(-0.4, 0.4);
y[i]+= depth * sin(alpha); // + random(-0.4, 0.4);
if (y[i] > height) {
y[i] = 0;
x[i] = random(0, width);
}
x[i]= x[i]%width;
fill(col[i], 4); //Comment if you don't want to use an image;
ellipse(x[i], y[i], 2, 2);
}
}
float customNoise(float x, float y) {
return pow(sin(0.9*x + noise(x, y)*map(mouseX, 0, width, 0, 5)*y), 3);
}