• fullscreen
  • FFTPolarPlot.pde
  • import ddf.minim.*;
    import ddf.minim.signals.*;
    import ddf.minim.analysis.*;
    import ddf.minim.effects.*;
    
    Minim minim;
    FFT fft;
    AudioInput in;
    int bufferSize = 512;
    int fftSize = floor(bufferSize*.5f)+1;
    //draw
    float ai = TWO_PI/fftSize;
    
    void setup(){
      size(400,400,P2D);
      smooth();
      noStroke();
      colorMode(HSB,fftSize,100,100);
      initSound();
    }
    
    void draw(){
      background(0,0,100);
      fft.forward(in.right);
      for(int i = 0; i < fftSize; i++){
        float band = fft.getBand(i);
        fill(i,150+100*(band/10),100,100);
        arc(200,200,200+band * (i+1),200+band * (i+1),ai*i,ai*(i+1));
      }
    }
    void initSound(){
      minim = new Minim(this);
      in = minim.getLineIn(Minim.STEREO, 512);
      fft = new FFT(in.bufferSize(), in.sampleRate());
    }
    void stop()
    {
      in.close();
      minim.stop();
      super.stop();
    }
    

    code

    tweaks (0)

    about this sketch

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

    license

    advertisement


    George Profenza

    FFTPolarPlot

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

    Using Minim library for basic FFT plot.

    A quick recorded demo is available here: http://www.vimeo.com/23485120

    George Profenza
    10 May 2011
    Oh, Please click Trust/Allow as the sketch needs to access microphone data. Thanks :)
    Asher Salomon
    30 May 2011
    I tried using your code in my sketch and when I tried uploading it it didn't work. What's the trick to uploading a minim sketch?
    George Profenza
    30 May 2011
    Hi Asher, That's a good point, I should've mentioned that. Because the applet is accessing the microphone, permissions are involved and you need to sign the applet with a certificate. You can use temporarily use a self-signed certificate. There is a very good guide on the Processing Wiki (http://wiki.processing.org/w/Sign_an_Applet). HTH
    Hi George! I just found your sketch and it's great! I'm a newbie in Processing so I was reading your code and I don't know how do you get the value of "f" in the following line:
    int fftSize = floor(bufferSize*.5f)+1;

    Can you help me out? Thanks!
    @thejokercharacter .5f is the same as 0.5f In that case the f is a compiler flag to tell java explicitly to treat the value as a float (f) and not a double. In the Processing IDE you don't need to worry about that, using 0.5 will work just fine. The f is there to keep eclipse from nagging.

    A simpler way to write that line is:
    int fftSize = (bufferSize/2)+1;

    HTH
    You need to login/register to comment.