#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# How to make background, strokes, and fills change colors based on an audio input?

edited November 2017

I've been playing with this code for a cube morphing size and shape and I would like to have the colors of all the objects and backround, change based on an audio input. sort of like a music visualizer but nothing is reactive to the music besides the color, i know there is a such thing as a minim library but not sure how to use it or match it to colors changing. Ive appropriated most of this code because I'm still new to processing, I've been able to make the colors change randomly but I would like to have the colors change based on an audacity file I've made. here is the code I've been altering,

float t; float theta; int maxFrameCount = 1000;

int a = 101; // offset number int space = 100; // size of cube for for loops

color c1; color c2;

void setup(){ size(540,540, P3D); }

void draw(){ background(0); translate(width/2,height/2);

t = (float)frameCount/maxFrameCount; theta = TWO_PIt10;

// lights directionalLight(0, 245, 245, 300, 500, 500);
ambientLight(240, 240, 240);

// 3 nested for loops to create sides
for (int x = -space; x <= space; x += 20) { for (int y = -space; y <= space; y += 20) { for (int z = -space; z <= space; z += 20) {

``````// map size of small cubes with offset
float offSet = ((x*y*z))/a;
float sz = map(sin(theta-offSet), -1, 1, 0, -20);

color c1 = color(156,225,100);
color c2 = color((random(180,200)),(random(180,250)),(random(0,225)));
color c3 = color(5,0,225);
color c4 = color(255,0,230);
``````

if ((xyz)%30 == 0){ fill(c2); stroke(c3); } else { fill(c3); stroke(c4); }

``````// small blocks, 3 times to create cube
shp(x,y,z,sz);
shp(y,z,x,sz);
shp(z,x,y,sz);

}}}
``````

} // end loop

void shp(float x, float y, float z, float d){

``````     pushMatrix();
translate(x,y,z);
box(d*1.5);
popMatrix();
``````

}

is my goal far fetched or within reason? -thanks

Tagged: