How can i make the ball in the center growing with sound?

edited October 2017 in Library Questions

float distance = 0.0; float speed = 4; float objStep = 40;

color c1, c2; boolean useRect;

void setup(){ size(640, 640, P3D); rectMode(CENTER); mousePressed();

}

void mousePressed(){ c1 = color(255); c2 = color(167); useRect = random(1) < 0.5 ? true: false; }

void draw(){ background(0); lights(); translate(width / 2, height / 2); stroke(c2); strokeWeight(2); noFill(); for(float depth = 0; depth < 1500; depth += objStep){ pushMatrix(); translate(0, 0, depth - distance % objStep); float objSize = map(noise((distance + depth - distance % objStep) * 0.004), 0, 1, 50, 200); if(useRect){ rect(0, 0, objSize, objSize); } else { ellipse(0, 0, objSize, objSize); } popMatrix(); } distance += speed;

noStroke();

fill(255,0,0);

sphere(19);

}

Tagged:

Answers

  • Your sketch doesn't make any sound. Will you be adding some, or possibly listening to the user's microphone? In short, where is the "sound" you want to adjust the sphere's size coming from?

  • i want to add music in the code and according to the music i want the ball to grow , can i make this happen and how?

  • edited October 2017

    You will need to use a Library to get your sketch to play music. I suggest you try Minim. In the processing IDE menus, go to Sketch > Import Library... > Add Library..., then find the minim Library and install it. Restart processing and check the example that came with the library (File > Examples > Contributed Libraries > Minim) for one that works.

Sign In or Register to comment.