Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

simple sound reactive ellipse (please help)

$
0
0
hey all, im doing an art project but im new to code,
i need to make an ellipse start and expand each time a sound goes in pocessing
i already did the drawing based on a sketch from openprocessing, now i just need to make it start from sound and not from keypressed,
im using the minim library 

here is my code:


  1. ArrayList Circles = new ArrayList();
  2. Circle D;

  3. import ddf.minim.*;  //minim audio input
  4. Minim minim;
  5. AudioInput in;
  6. int s = 1700;    // audio input sensivity
  7.    
  8. void setup(){
  9.   size(600,600);
  10.   smooth();
  11.   
  12.     minim = new Minim(this);
  13.     minim.debugOn();
  14.   in = minim.getLineIn(Minim.MONO, 64);

  15. }
  16.   
  17. void draw(){
  18.   background(0);
  19.   
  20.   strokeWeight(3);
  21.   for (int i=0; i<Circles.size(); i++){
  22.     Circle D = (Circle) Circles.get(i);
  23.     D.run();
  24.   }
  25. }
  26.  
  27. class Circle {
  28.   
  29.   PVector pos;
  30.   color c;
  31.   float s;
  32.   int age;
  33.   
  34.   Circle( PVector _pos, color _c, float _s  ) {
  35.     pos = _pos;
  36.     c = _c;
  37.     s = _s;
  38.   }
  39.   
  40.   void run() {
  41.     render();
  42.     age += 3;
  43.     if(age > 600) {
  44.       Circles.remove(this);
  45.     }
  46.   }
  47.   
  48.   void render() {
  49.     stroke(255,255,255);
  50.     fill(255, 255, 255, 155-age*0.35);
  51.     ellipse( width/2, height/2, age*1.5, age*1.5 );
  52.   }
  53. }
  54.   
  55. void keyPressed(){
  56.     
  57.    
  58.   Circle D = new Circle( new PVector(random(width), random(height)), color(100),0);
  59.   Circles.add(D);
  60.   }
  61.   

  62.  
  63.  
  64. void stop(){
  65.   in.close();
  66.   minim.stop();
  67.   super.stop();
  68. }
thank you very much for your time! 
i really apreciate all the help!

Viewing all articles
Browse latest Browse all 1768

Trending Articles