• fullscreen
  • music.pde
  • pics.pde
  • import ddf.minim.analysis.*;
    import ddf.minim.*;
    
    Minim minim;
    AudioPlayer jingle;
    FFT fft;
    
    
    
    void stop()
    {
      // always close Minim audio classes when you finish with them
      jingle.close();
      minim.stop();
      
      super.stop();
    }
    
    float h=3;
    float speed=0.2;
    int i=0;
    color[] arr;
    float[] t;
    //float t=1;
    float sp=5;
    float f=0;
    boolean ch=false;
    
    
    void setup()
    {
      size(300,200,P2D);
      arr=new color[3000];
      t=new float[1000];
        for(int o=0;o<1000;o++)
      {
      t[o]=255;
      }
      
       minim = new Minim(this);
      
      jingle = minim.loadFile("jingle.mp3", 2048);
      jingle.loop();
      fft = new FFT(jingle.bufferSize(), jingle.sampleRate());
      fft.linAverages(128);
      rectMode(CORNERS);
    }
    
    
    void draw()
    {
    fft.forward(jingle.mix);
      int w = int(fft.specSize()/128);
      
      i=0;
      for(int o=0;o<1000;o++)
      t[o]=constrain(t[o],0,255);
      
     background(0);
     stroke(255);
     strokeWeight(5);
     noFill();
     pushMatrix();
     translate(width/2,height/2);
      rotate(f);
     ellipse(60,0,fft.getAvg(fft.avgSize()/20)*8+100,fft.getAvg(fft.avgSize()/20)*8+100);
     ellipse(-60,0,fft.getAvg(fft.avgSize()/20)*8+100,fft.getAvg(fft.avgSize()/20)*8+100);
     popMatrix();
     f+=PI/90;
      
      
      loadPixels();
      
       colorMode(HSB);
      for(int o=0;o<3000;o++)
      {
      arr[o]=color(h,150,170);
      }
      if(h>254 || h<1)
      speed=-speed;
       h+=speed;
      
      
      colorMode(RGB);
      for(int x=5;x<width;x+=10)
      for(int y=5;y<height;y+=10)
       {
         int loc=y*width+x;
         float r=red(pixels[loc]);
         float g=green(pixels[loc]);
         float b=blue(pixels[loc]);
        
        for(int x1=x-5;x1<x+5;x1++)
        for(int y1=y-5;y1<y+5;y1++)
        {
          loc=y1*width+x1;
          if(color(r,g,b)==color(255))
          {
            
            
            t[i]=0;
          }
       
          pixels[loc]=color(red(arr[i])-dist(x,y,x1,y1)*20-t[i],green(arr[i])-dist(x,y,x1,y1)*20-t[i],blue(arr[i])-dist(x,y,x1,y1)*20-t[i]);
          
       
        }
        if(t[i]<50)
        t[i]+=2;
        else
        if(t[i]<100)
        t[i]+=1;
        else
        {
        if(t[i]<150)
        t[i]+=0.15;
        else 
        {
        if(t[i]<200)
        t[i]+=0.05;
        else
        t[i]+=0.01;
        }
        }
        i++;
      }
      
    
      updatePixels();
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Yuriy Flyud

    sound circles

    Add to Faves Me Likey@! 2
    You must login/register to add this sketch to your favorites.

    one of my first works with pixels and sound.

    You need to login/register to comment.