• fullscreen
  • load_settings.pde
  • mouseWheel.pde
  • openprocessing.pde
  • void loadSettings(int i) {
      try {
        lastMCx=settings[i][0];
        lastMCy=settings[i][1];
        vt=settings[i][2];
        color_start=settings[i][3];
        color_range=settings[i][4];
        ringsize=settings[i][5];
      }
      catch(ArrayIndexOutOfBoundsException e) {
      }
    }
    
    
    void mousewheelstart(){
      addMouseWheelListener(new java.awt.event.MouseWheelListener() { 
        public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { 
          mouseWheel(evt.getWheelRotation());
        }
      }
      ); 
    }
    
    void mouseWheel(int delta) {
      if(delta>0){
        vt++;
      }else{
        vt--;
      }
      if(vt<=1){
        vt=1;
      }
      
    }
    
    import ddf.minim.analysis.*;
    import ddf.minim.*;
    
    Minim minim;
    AudioPlayer player;
    FFT fft;
    
    int lastMCx=350;
    int lastMCy=718;
    
    int vt;
    float pfftBand[];
    
    int color_start=30;
    int color_range=255;
    
    int ringsize=400;
    
    int settings[][]= {
      {
        483, 628, 15, 30, 255, 300
      }
      , {
        350, 717, 135, 30, 255, 400
      }
      , {
        244, 700, 50, 30, 255, 300
      }
    };
    
    
    public void init() {
      mousewheelstart();
      super.init();
    }
    
    
    void setup()
    {
      size(800, 800, P2D);
      //smooth();
      textFont(createFont("ArialMT", 20));
    
    
    
      colorMode(HSB);
      minim = new Minim(this);
    
      player = minim.loadFile("Faith  Touhou Unplugged_Classic 115_track1.mp3", 2048);
      player.loop();
      fft = new FFT(player.bufferSize(), player.sampleRate());
    
    
    
      pfftBand=new float[fft.specSize()];
      for (int i = 0; i < fft.specSize(); i++)
      {
        pfftBand[i]=0;
      }
      vt=135;
      frameRate(60);
      loadSettings(0);
    }
    
    
    void fadescr(int r, int g, int b, int sp) { 
      int red, green, blue;
      loadPixels();
      for (int i = 0; i < pixels.length; i++) {
        red = (pixels[i] >> 16) & 0x000000ff; 
        green = (pixels[i] >> 8) & 0x000000ff; 
        blue = pixels[i] & 0x000000ff; 
        pixels[i] = (((red+((r-red)>>sp)) << 16) | ((green+((g-green)>>sp)) << 8) | (blue+((b-blue)>>sp)));
      } 
      updatePixels();
    }
    
    void draw()
    {
      println(frameRate);
      fadescr(0, 0, 0, 4);
    
    
      //lastMCx=mouseX;
      //lastMCy=mouseY;
    
      //translate(mouseX-width/2, mouseY-height/2);
      fft.forward(player.mix);
    
      pushMatrix();
      translate(width/2, height/2);
      rotate(-HALF_PI);
      for (int i=0; i<2; i++) {
        scale(1, -1);
        strokeWeight(2);
        noFill();
        beginShape();
        float sca=map(height-lastMCy, 0, height, 0, 1000);
        int vertexes=min(fft.specSize()-1, (vt)*6+1);
        for (int j=0; j<vertexes; j++) {
          float val=0;
          try {
            val=sqrt(pfftBand[j], 2)*sca;
          }
          catch(ArrayIndexOutOfBoundsException e) {
          }
          stroke(((color_range/float(vertexes)*j)+color_start)%255, 255, 255, 80);
          vertex(cos((TWO_PI/float(vt))*j)*(ringsize-val), sin((TWO_PI/float(vt))*j)*(ringsize-val));
        }
        endShape();
      }
      popMatrix();
    
    
      if (mousePressed) {
        fill(255);
        text(vt, 20, 20);
      }
      for (int i = 0; i < fft.specSize(); i++)
      {
        pfftBand[i]+=(fft.getBand(i)-pfftBand[i])/map(lastMCx, 0, width, 5, 50);
      }
      //println("delay: "+map(mouseX, 0, width, 5, 50));
    }
    
    
    float sqrt(float val, float root) {
      for (int i=0; i<root; i++) {
        val=sqrt(val);
      }
      return(val);
    }
    
    void keyPressed() {
      if (key>='1' && key<='9') {
        loadSettings(key-'1');
      }
      else if (key!=27) {
        player.pause();
        setup();
      }
    }
    
    void stop()
    {
      player.close();
      minim.stop();
    
      super.stop();
    }
    
    void mouseClicked() {
      lastMCx=mouseX;
      lastMCy=mouseY;
      println(mouseX+" "+mouseY);
    }
    
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement

    Ranking

    music visualization v3

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

    Well ther it is:
    My new music visualization.

    Controlls:
    1-3 diffrent pre defined values for displaying and value mapping

    Mouse Press:
    x - speed of the vertexes
    y - size (just a simple scale(...))



    The song is called: "Faith Touhou Unplugged_Classic 115"

    jjh
    11 Jun 2013
    This is great, a really diverse range of patterns from the mouse interaction. Particularly like the fading of the lines
    You need to login/register to comment.